Skip to content

Commit

Permalink
GitHub actions runner: fixed version of python; needs to be "3.10", a…
Browse files Browse the repository at this point in the history
…s 3.10 is parsed as 3.1
  • Loading branch information
fititnt committed Nov 28, 2021
1 parent 991fdde commit f85c9b4
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/hxltm-computo_testum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ jobs:
strategy:
matrix:
# python-version: [3.7, 3.8, 3.9, 3.10]
python-version: [3.7, 3.8, 3.9, 3.10]
# python-version: ["3.7", "3.8", "3.9", "3.10-dev"]
python-version: ["3.7", "3.8", "3.9", "3.10"]

# # Don't run https://github.com/nektos/act locally. Can be removed later.
# if: ${{ !env.ACT }}
Expand Down
48 changes: 40 additions & 8 deletions bin/hxltmcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5029,6 +5029,10 @@ class HXLTMOntologia:
>>> ontologia.est_validum_ad_regula('#item+conceptum+codicem')
True
>>> ontologia.est_validum_ad_regula('#item+conceptum+codicem',
... 'conceptum_classem')
True
#>>> ontologia.quod_rem_statum()
{'accuratum': None, 'crudum': [], 'crudum_originale': [], \
'XLIFF': 'initial', 'UTX': 'provisional'}
Expand All @@ -5049,6 +5053,9 @@ class HXLTMOntologia:
# dēprecātum, https://en.wiktionary.org/wiki/deprecatus#Latin
_deprecatum: Type[set] = set()

# tolerātum, https://en.wiktionary.org/wiki/toleratus#Latin
_deprecatum_toleratum: bool = True

def __init__(self, ontologia: Dict, vacuum: bool = False):
"""
_[eng-Latn] Constructs all the necessary attributes for the
Expand All @@ -5060,15 +5067,36 @@ def __init__(self, ontologia: Dict, vacuum: bool = False):
else:
self.crudum = ontologia

def _ontologia_regulam_regex(self, clavem: str) -> str:
def _ontologia_regulam_regex(self, clavem: Union[list, str]) -> list:
"""_ontologia_regulam_regex
"""
resultatum = []
# return self.crudum['ontologia_regulam']

# print(self.crudum['ontologia_regulam'])

try:
return self.crudum['ontologia_regulam'][clavem]
if not isinstance(clavem, list):
clavem = [clavem]

for item in clavem:
resultatum.append(self.crudum['ontologia_regulam'][item])
if self._deprecatum_toleratum and \
item + '_deprecatum' in self.crudum['ontologia_regulam']:
resultatum.append(
self.crudum['ontologia_regulam'][item + '_deprecatum'])
# return self.crudum['ontologia_regulam'][clavem]['regex']
except:
clavem_est = []
if 'ontologia_regulam' in self.crudum:
# and
# self.crudum['ontologia_regulam']['ontologia_regulam']:
clavem_est = list(self.crudum['ontologia_regulam'].keys())
raise ValueError(
'Non {0} ad ontologia_regulam.{0}.regex'.format(clavem))
'Non {0} ad ontologia_regulam.{0}.regex. '
'Optionem {1}'.format(str(clavem), str(clavem_est)))

return resultatum

def hxl_de_aliud_nomen_breve(self, structum=False):
"""HXL attribūtum de aliud nōmen breve (cor.hxltm.215.yml)
Expand Down Expand Up @@ -5169,7 +5197,7 @@ def de(self, dotted_key: str, # pylint: disable=invalid-name
def est_validum_ad_regula(
self,
hxlhashtag: str,
regulam_clavem: str = None
regulam_clavem: Union[list, str] = None
) -> bool:
"""est_validum_ad_regula est validum ad rēgulam? [ ontologia_regulam ]
Expand All @@ -5189,12 +5217,16 @@ def est_validum_ad_regula(
bool: Python True est validum
"""
if regulam_clavem is None:
regulam_clavem = 'abstractum_aut_concretum'
regulam_clavem = ['hxltm_basim', 'hxltm_basim']

regula = self._ontologia_regulam_regex(regulam_clavem)
regula_regex = re.compile(regula['regex'])
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)):
return False

return bool(regula_regex.match(hxlhashtag))
return True

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

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

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

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

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

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

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

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

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

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

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

terminum_classem:
regex: '(^#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+is_215+rem
#item+terminum+est_linguam+v_linguam_maximum,
#item+terminum+est_linguam+v_linguam_a
#item+terminum+est_linguam+v_linguam
#item+terminum+de_linguam
#item+terminum+est_linguam_fonte
#item+terminum+est_linguam_objectivum
#item+terminum+de_linguam_fontem
#item+terminum+de_linguam_objectivum
#item+terminum+i_en+i_eng+is_latn+rem

# Regexes test
# - https://regex101.com/r/2VpoTS/1
# - Delete https://regex101.com/delete/aCOj7ECKu1kLyJOCMRZS2SeL


## TBX Basic 3.1 (http://www.terminorgs.net/downloads/TBX_Basic_Version_3.1.pdf)
# 5 Mandatory data categories
# There are only two mandatory data categories in TBX-Basic: term, and language.
Expand Down

0 comments on commit f85c9b4

Please sign in to comment.