Skip to content

Commit

Permalink
hxltmcli (#23): created an Ad-Hoc normam (actually not a build in for…
Browse files Browse the repository at this point in the history
…mat from HXLTM, but one way to minimal capabilities to use liquid tags to export files without resort to ruby, as used on hapi.etica.ai)
  • Loading branch information
fititnt committed Oct 7, 2021
1 parent 0186daf commit 053e30e
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 15 deletions.
60 changes: 47 additions & 13 deletions bin/hxltmcli
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,14 @@ class HXLTMArgumentum: # pylint: disable=too-many-instance-attributes

if hasattr(args_rem, 'objectivum_formulam') and \
args_rem.objectivum_formulam:
self.objectivum_formulam = args_rem.objectivum_formulam
# self.objectivum_formulam_archivum = args_rem.objectivum_formulam
# Open a file: file
file_ = open(args_rem.objectivum_formulam, mode='r')
# self.objectivum_formulam_crudum = file_.read()
self.objectivum_formulam = file_.read()
file_.close()
# self.objectivum_formulam_crudum = args_rem.objectivum_formulam
# print(self.objectivum_formulam)
self.objectivum_formatum = 'formatum-speciale'

elif hasattr(args_rem, 'objectivum_formatum'):
Expand Down Expand Up @@ -3641,14 +3648,18 @@ class HXLTMInFormatum(ABC):
"""
resultatum = []

liquid_template = self.normam['formatum']['corporeum']
if 'formatum' in self.normam and \
'corporeum' in self.normam['formatum'] and \
self.normam['formatum']['corporeum']:

for rem in self.de_rem():
liquid_context = {'rem': str(rem)}
liquid_context = rem.contextum()
resultatum.append(
self.de_liquid(liquid_template, liquid_context)
)
liquid_template = self.normam['formatum']['corporeum']

for rem in self.de_rem():
liquid_context = {'rem': str(rem)}
liquid_context = rem.contextum()
resultatum.append(
self.de_liquid(liquid_template, liquid_context)
)
return resultatum

def datum_finale(self) -> List:
Expand Down Expand Up @@ -3686,14 +3697,31 @@ class HXLTMInFormatum(ABC):
"""
resultatum = []

liquid_template = self.normam['formatum']['corporeum']
# print('oi')

for rem in self.de_rem():
liquid_context = {'rem': str(rem)}
liquid_context = rem.contextum()
if hasattr(self.hxltm_asa.argumentum , 'objectivum_formulam') and \
self.hxltm_asa.argumentum.objectivum_formulam:

liquid_template = self.hxltm_asa.argumentum.objectivum_formulam
liquid_context = {}
resultatum.append(
self.de_liquid(liquid_template, liquid_context)
)
# print('oi3')
# print('oi3')

# if 'formatum' in self.normam and \
# 'corporeum' in self.normam['formatum'] and \
# self.normam['formatum']['corporeum']:

# liquid_template = self.normam['formatum']['corporeum']

# for rem in self.de_rem():
# liquid_context = {'rem': str(rem)}
# liquid_context = rem.contextum()
# resultatum.append(
# self.de_liquid(liquid_template, liquid_context)
# )
return resultatum

def de_lineam(self) -> Type['HXLTMRemIterandum']:
Expand Down Expand Up @@ -3899,6 +3927,12 @@ Salvi, {{ i }}! \
for rem in finale:
print(rem)

especiale = self.datum_especiale()

if len(especiale) > 0:
for rem in especiale:
print(rem)

def quod_globum_valorem(self) -> Dict:
"""Quod globum valorem?
Expand Down Expand Up @@ -3956,7 +3990,7 @@ class HXLTMInFormatumEpeciale(HXLTMInFormatum):
[eng-Latn]_
"""

ONTOLOGIA_NORMAM = '-1'
ONTOLOGIA_NORMAM = 'Ad-Hoc'


class HXLTMInFormatumTabulamRadicem(HXLTMInFormatum):
Expand Down
27 changes: 27 additions & 0 deletions ontologia/cor.hxltm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,33 @@ fontem_archivum_extensionem_regex:
# tag::normam[]
# Trivia: normam, https://en.wiktionary.org/wiki/norma#Latin
normam:

#### Ad Hoc template ________________________________________________________
# tag::normam_Ad-Hoc[]
Ad-Hoc:
__meta:
archivum_extensionem:
descriptionem: |
_[eng-Latn]
Ad Hoc template
[eng-Latn]_
normam:
- <https://github.com/HXL-CPLP/Auxilium-Humanitarium-API/wiki/Index>
nomen:
eng-Latn: 'Ad Hoc template'
situs_interretialis:
referens_officinale:
- <https://github.com/HXL-CPLP/Auxilium-Humanitarium-API/wiki/Index>

asa:
modus_operandi: []

formatum:
initiale: false
corporeum: false
finale: False
# end::normam_Ad-Hoc[]

#### CSV-3: Source + Target + Comment (draft) _______________________________
# tag::normam_CSV-3[]
CSV-3:
Expand Down
4 changes: 2 additions & 2 deletions testum/hxltm/manuale-testum.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ printf "\n\n\n\tTESTUM 012 Hapi_schemam_un_htcds\n\n"
echo hxltmcli "$Hapi_schemam_un_htcds" "$Hapi_schemam_un_htcds_RESULTATUM_XLIFF_LOCAL" --objectivum-XLIFF --fontem-linguam eng-Latn@en --objectivum-linguam por-Latn@pt
hxltmcli "$Hapi_schemam_un_htcds" "$Hapi_schemam_un_htcds_RESULTATUM_XLIFF_LOCAL" --objectivum-XLIFF --fontem-linguam eng-Latn@en --objectivum-linguam por-Latn@pt

# fititnt@bravo:/workspace/git/EticaAI/HXL-Data-Science-file-formats/testum/hxltm$ hxltmcli schemam-un-htcds.tm.hxl.csv resultatum/schemam-un-htcds.xlf --objectivum-XLIFF --fontem-linguam eng-Latn@en
# hxltmcli schemam-un-htcds.tm.hxl.csv resultatum/schemam-un-htcds.xlf --objectivum-XLIFF --fontem-linguam eng-Latn@en

# hxltmcli schemam-un-htcds.tm.hxl.csv --objectivum-formulam testum/hxltm/formulam/exemplum-linguam.🗣️.json --objectivum-linguam por-Latn@pt
# hxltmcli schemam-un-htcds.tm.hxl.csv --objectivum-formulam formulam/exemplum-linguam.🗣️.json --objectivum-linguam por-Latn@pt

# To revert only one file that keeps changing even with same input
# git checkout -- testum/hxltm/resultatum/hxltm-exemplum-linguam.tmx
Expand Down

0 comments on commit 053e30e

Please sign in to comment.