Skip to content

Commit

Permalink
#11: cor.hxltm.215.yml ontologia_regulam improved
Browse files Browse the repository at this point in the history
  • Loading branch information
fititnt committed Nov 28, 2021
1 parent f85c9b4 commit 28df3f2
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 21 deletions.
57 changes: 54 additions & 3 deletions bin/hxltmcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5033,6 +5033,16 @@ class HXLTMOntologia:
... 'conceptum_classem')
True
>>> ontologia.quod_rem_ab_regula('+i_en+i_eng+is_latn+is_215', 'iso15924_a')
['latn']
>>> ontologia.quod_rem_ab_regula('+i_en+i_eng+is_latn+is_215', 'iso15924_n')
['215']
>>> ontologia.quod_rem_ab_regula(
... '#item+terminum,#item+conceptum', 'hxltm_basim')
['#item+terminum']
#>>> ontologia.quod_rem_statum()
{'accuratum': None, 'crudum': [], 'crudum_originale': [], \
'XLIFF': 'initial', 'UTX': 'provisional'}
Expand Down Expand Up @@ -5211,7 +5221,8 @@ def est_validum_ad_regula(
Args:
hxlhashtag (str): HXL Hashtag
ontologia_regex (str, optional): ontologia_regulam clavem
ontologia_regex (Union[list, str], optional):
ontologia_regulam clavem
Returns:
bool: Python True est validum
Expand All @@ -5222,12 +5233,52 @@ def est_validum_ad_regula(
regula_multipla = self._ontologia_regulam_regex(regulam_clavem)
# return list(regula_multipla.keys())
for item in regula_multipla:
regula_regex = re.compile(r"{0}".format(item['regex']))
if not bool(regula_regex.match(hxlhashtag)):
regula_regex = re.compile(
r"{0}".format(item['existere']), re.IGNORECASE)
# if not bool(regula_regex.match(hxlhashtag)):
if not bool(regula_regex.search(hxlhashtag)):
return False

return True

def quod_rem_ab_regula(
self,
hxlhashtag: str,
regulam_clavem: Union[list, str] = None
) -> bool:
"""quod_rem_ab_regula est rem ad rēgulam? [ ontologia_regulam ]
_[eng-Latn]
Literal translation of 'est rem ad rēgulam? ':
what is the matter by rule?
[eng-Latn]_
Args:
hxlhashtag (str): HXL Hashtag
ontologia_regex (str, optional): ontologia_regulam clavem
Returns:
bool: Python True est validum
"""
resultatum = []

regula_multipla = self._ontologia_regulam_regex(regulam_clavem)
# return list(regula_multipla.keys())
for item in regula_multipla:
regula_regex = re.compile(
r"{0}".format(item['rem']), re.IGNORECASE)

rem = regula_regex.finditer(hxlhashtag)
if rem:
for item in rem:
resultatum.append(item.group())
# for group in item.groups():
# resultatum.append(group)

# if not bool(regula_regex.match(hxlhashtag)):
# return False
return resultatum

def quod_aliud(self, aliud_typum: str, aliud_valorem: str) -> Dict:
"""Quod Aliud?
Expand Down
62 changes: 44 additions & 18 deletions ontologia/cor.hxltm.215.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3007,52 +3007,78 @@ ontologia_regulam:

# abstractum, https://en.wiktionary.org/wiki/abstractus#Latin
abstractum:
regex: "^#meta"
existere: "^#meta"

# classem, https://en.wiktionary.org/wiki/classis#Latin
conceptum_classem:
regex: '(^#item|^#meta)\+conceptum'
existere: '(^#item|^#meta)\+conceptum'

# concrētum, https://en.wiktionary.org/wiki/concretus
concretum:
regex: "^#item"
existere: "^#item"

# Glottocode, https://glottolog.org/
glotto:
# 'port1283' ad '+ig_port1283+'
rem: '(?<=ig_)([\w]{4}[\d]{4})'

# basim, https://en.wiktionary.org/wiki/basis#Latin
hxltm_basim:
# regex: "^#item|^#meta"
regex: '(^#item|^#meta)(\+conceptum|\+linguam|\+terminum)'
existere: '(^#item|^#meta)(\+conceptum|\+linguam|\+terminum)'
rem: '(^#item|^#meta)(\+conceptum|\+linguam|\+terminum)'

linguam_classem:
regex: '(^#item|^#meta)\+linguam'
# HXL vacabularies, +v_(...)
hxl_v:
existere: '(\+v_[\w|\d]+)'
rem: '(?<=\+)(v_[\w|\d]+)'

quid_iso639_1:
iso639_1:
# 'en' in '+i_en'
regex: '(?<=i_)([\w]{2})\+'
rem: '(?<=i_)([\w]{2})\+'

quid_iso639_3:
iso639_3:
# 'eng' in '+i_eng'
regex: '(?<=i_)([\w]{3})\+'
rem: '(?<=i_)([\w]{3})\+'

quid_iso15924:
iso15924:
# ISO 15924: 'latn' in '+is_latn+'
regex: 'TODO'
rem: 'TODO'

quid_iso15924_a:
iso15924_a:
# ISO 15924: 'latn' in '+is_latn+'
regex: '(?<=is_)([\w]{4})\+'
rem: '(?<=is_)([\w]{4})'

quid_iso15924_n:
iso15924_n:
# ISO 15924: '215' in +is_215+
regex: '(?<=is_)([\d]{3})\+'
rem: '(?<=is_)([\d]{3})'

linguam_classem:
existere: '(^#item|^#meta)\+linguam'

# explicitum, https://en.wiktionary.org/wiki/implicitus#Latin
# implicitum, https://en.wiktionary.org/wiki/explicitus#Latin
# The bare minimum to be considered linguan is i_www+i_Wwww or i_www+i_nnn
linguam_basim_explicitum:
existere: '(\+i_([\w]{2}))([\w]{4}[\d]{4})?.*(\+is_[\w]{4}|\+is_[\d]{3}){1}' # needs more test
# existere: '(\+is_([\w]{4})|([\d]{3}))'

# Implicitly language, value present as value on another column
linguam_basim_implicitum_de:
existere: '(\+de_linguam_fontem|\+de_linguam_objectivum|\+de_linguam)'

# Implicitly language, this column have values from equivalent de_linguam*
linguam_basim_implicitum_est:
existere: '(\+est_linguam_fontem|\+est_linguam_objectivum|\+est_linguam)'

terminum_classem:
regex: '(^#item|^#meta)\+terminum'
existere: '(^#item|^#meta)\+terminum'

### Example test cases
#item+conceptum
#meta+conceptum
#item+conceptum+codicem
#meta+linguam+i_en+i_eng+is_latn+rem
#meta+linguam+i_en+i_eng+ig_port1283+is_latn+rem
#meta+linguam+i_en+i_eng+is_215+rem
#item+terminum+est_linguam+v_linguam_maximum,
#item+terminum+est_linguam+v_linguam_a
Expand Down

0 comments on commit 28df3f2

Please sign in to comment.