Skip to content

Commit

Permalink
L999999999_0.py (#39): small refactoring (centralize redundant code)
Browse files Browse the repository at this point in the history
  • Loading branch information
fititnt committed May 23, 2022
1 parent 94ad142 commit a38ac83
Show file tree
Hide file tree
Showing 5 changed files with 211 additions and 680 deletions.
130 changes: 5 additions & 125 deletions officinam/999999999/0/999999999_10263485.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
# List,
)

from L999999999_0 import (
# hxltm_carricato,
TabulaAdHXLTM
)

import yaml

import xml.etree.ElementTree as XMLElementTree
Expand Down Expand Up @@ -425,131 +430,6 @@ def de_dotted(self, dotted_key: str, # pylint: disable=invalid-name
)


class TabulaAdHXLTM:
"""Tabula ad HXLTM
- tabula, f, s, nominativus, https://en.wiktionary.org/wiki/tabula
- ad (+ accusativus),https://en.wiktionary.org/wiki/ad#Latin
- ex (+ ablativus)
- HXLTM, https://hxltm.etica.ai/
"""
methodus_ex_tabulae: dict = {}
# methodus_ex_tabulae: dict = {}
objectivum_formato: str = 'hxltm_csv'
methodus: str = ''

# _hxltm: '#meta+{caput}'

# '#meta+{{caput_clavi_normali}}'
_hxltm_hashtag_defallo: str = '#meta+{{caput_clavi_normali}}'
_hxl_hashtag_defallo: str = '#meta+{{caput_clavi_normali}}'

def __init__(
self,
methodus_ex_tabulae: dict,
objectivum_formato: str,
methodus: str,
):
"""__init__ _summary_
Args:
methodus_ex_tabulae (dict):
"""
self.methodus_ex_tabulae = methodus_ex_tabulae
self.objectivum_formato = objectivum_formato
self.methodus = methodus

def caput_translationi(self, caput: list) -> list:
"""Caput trānslātiōnī
- trānslātiōnī, f, s, dativus, https://en.wiktionary.org/wiki/translatio
- caput, n, s, nominativus, https://en.wiktionary.org/wiki/caput#Latin
Args:
caput (list): _description_
Returns:
list: _description_
"""

# if self.objectivum_formato.find('hxltm') > -1:
# # neo_caput = map(self.clavis_ad_hxl, caput, 'hxltm')
# # neo_caput = map(self.clavis_ad_hxl, caput, 'hxltm')
# neo_caput = map(self.clavis_ad_hxl, caput)
# # neo_caput = map(self.clavis_ad_hxl, caput)
# if self.objectivum_formato.find('hxl') > -1:
# # neo_caput = map(self.clavis_ad_hxl, caput, 'hxl')
# neo_caput = map(self.clavis_ad_hxl, caput)
if self.objectivum_formato.find('hxl') > -1:
neo_caput = map(self.clavis_ad_hxl, caput)
else:
neo_caput = map(self.clavis_normationi, caput)
return neo_caput

def clavis_normationi(self, clavis: str) -> str:
"""clāvis nōrmātiōnī
- clāvis, f, s, normativus, https://en.wiktionary.org/wiki/clavis#Latin
- nōrmātiōnī, f, s, dativus, https://en.wiktionary.org/wiki/normatio
Args:
clavis (str):
Returns:
str:
"""
if not clavis or len(clavis) == 0:
return ''
clavis_normali = clavis.strip().lower()\
.replace(' ', '_').replace('-', '_')

return clavis_normali

# def clavis_ad_hxl(self, clavis: str, classis: str = 'hxltm') -> str:
def clavis_ad_hxl(self, clavis: str) -> str:
"""clavis_ad_hxltm
- clāvis, f, s, normativus, https://en.wiktionary.org/wiki/clavis#Latin
- nōrmātiōnī, f, s, dativus, https://en.wiktionary.org/wiki/normatio
Args:
clavis (str):
Returns:
str:
"""
# @TODO: generalize this block with 999999999_268072.py

# clavis_normationi = self.clavis_normationi(clavis)
clavis_normationi = clavis

if not clavis or len(clavis) == 0:
return ''

if self.objectivum_formato.find('hxltm') > -1:
neo_caput = 'hxltm_hashtag'
forma = self._hxltm_hashtag_defallo
# elif classis == 'hxl':
elif self.objectivum_formato.find('hxl') > -1:
neo_caput = 'hxl_hashtag'
forma = self._hxl_hashtag_defallo

if clavis_normationi in self.methodus_ex_tabulae['caput'].keys():
if self.methodus_ex_tabulae['caput'][clavis_normationi] and \
neo_caput in self.methodus_ex_tabulae['caput'][clavis_normationi] and \
self.methodus_ex_tabulae['caput'][clavis_normationi][neo_caput]:
forma = self.methodus_ex_tabulae['caput'][clavis_normationi][neo_caput]

hxl_hashtag = forma.replace(
'{{caput_clavi}}', clavis)

hxl_hashtag = forma.replace(
'{{caput_clavi_normali}}', self.clavis_normationi(clavis))

return hxl_hashtag


if __name__ == "__main__":

est_cli = Cli()
Expand Down
130 changes: 2 additions & 128 deletions officinam/999999999/0/999999999_54872.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@
'https://www.w3.org/2018/09/rdf-data-viz/',
'https://rdf2svg.redefer.rhizomik.net/',
# 'http://robot.obolibrary.org/reason',
## Papers
# Papers
'https://www.w3.org/2009/12/rdf-ws/papers/ws21',
# https://en.wikipedia.org/wiki/Ontology_engineering
## 300 page book
# 300 page book
# - https://people.cs.uct.ac.za/~mkeet/files/OEbook.pdf
# - https://people.cs.uct.ac.za/~mkeet/OEbook/OEsoftware.html#OElang
]
Expand Down Expand Up @@ -428,132 +428,6 @@ def actio(self):
# print('failed')


# @TODO remove TabulaAdHXLTM from this file
class TabulaAdHXLTM:
"""Tabula ad HXLTM
- tabula, f, s, nominativus, https://en.wiktionary.org/wiki/tabula
- ad (+ accusativus),https://en.wiktionary.org/wiki/ad#Latin
- ex (+ ablativus)
- HXLTM, https://hxltm.etica.ai/
"""
methodus_ex_tabulae: dict = {}
# methodus_ex_tabulae: dict = {}
objectivum_formato: str = 'hxltm_csv'
methodus: str = ''

# _hxltm: '#meta+{caput}'

# '#meta+{{caput_clavi_normali}}'
_hxltm_hashtag_defallo: str = '#meta+{{caput_clavi_normali}}'
_hxl_hashtag_defallo: str = '#meta+{{caput_clavi_normali}}'

def __init__(
self,
methodus_ex_tabulae: dict,
objectivum_formato: str,
methodus: str,
):
"""__init__ _summary_
Args:
methodus_ex_tabulae (dict):
"""
self.methodus_ex_tabulae = methodus_ex_tabulae
self.objectivum_formato = objectivum_formato
self.methodus = methodus

def caput_translationi(self, caput: list) -> list:
"""Caput trānslātiōnī
- trānslātiōnī, f, s, dativus, https://en.wiktionary.org/wiki/translatio
- caput, n, s, nominativus, https://en.wiktionary.org/wiki/caput#Latin
Args:
caput (list): _description_
Returns:
list: _description_
"""

# if self.objectivum_formato.find('hxltm') > -1:
# # neo_caput = map(self.clavis_ad_hxl, caput, 'hxltm')
# # neo_caput = map(self.clavis_ad_hxl, caput, 'hxltm')
# neo_caput = map(self.clavis_ad_hxl, caput)
# # neo_caput = map(self.clavis_ad_hxl, caput)
# if self.objectivum_formato.find('hxl') > -1:
# # neo_caput = map(self.clavis_ad_hxl, caput, 'hxl')
# neo_caput = map(self.clavis_ad_hxl, caput)
if self.objectivum_formato.find('hxl') > -1:
neo_caput = map(self.clavis_ad_hxl, caput)
else:
neo_caput = map(self.clavis_normationi, caput)
return neo_caput

def clavis_normationi(self, clavis: str) -> str:
"""clāvis nōrmātiōnī
- clāvis, f, s, normativus, https://en.wiktionary.org/wiki/clavis#Latin
- nōrmātiōnī, f, s, dativus, https://en.wiktionary.org/wiki/normatio
Args:
clavis (str):
Returns:
str:
"""
if not clavis or len(clavis) == 0:
return ''
clavis_normali = clavis.strip().lower()\
.replace(' ', '_').replace('-', '_')

return clavis_normali

# def clavis_ad_hxl(self, clavis: str, classis: str = 'hxltm') -> str:
def clavis_ad_hxl(self, clavis: str) -> str:
"""clavis_ad_hxltm
- clāvis, f, s, normativus, https://en.wiktionary.org/wiki/clavis#Latin
- nōrmātiōnī, f, s, dativus, https://en.wiktionary.org/wiki/normatio
Args:
clavis (str):
Returns:
str:
"""
clavis_normationi = self.clavis_normationi(clavis)

if not clavis or len(clavis) == 0:
return ''
# print(classis)
# neo_caput = 'hxl_hashtag'
# forma = self._hxl_hashtag_defallo
# if classis == 'hxltm' or not classis:
if self.objectivum_formato.find('hxltm') > -1:
neo_caput = 'hxltm_hashtag'
forma = self._hxltm_hashtag_defallo
# elif classis == 'hxl':
elif self.objectivum_formato.find('hxl') > -1:
neo_caput = 'hxl_hashtag'
forma = self._hxl_hashtag_defallo

if clavis_normationi in self.methodus_ex_tabulae['caput'].keys():
if self.methodus_ex_tabulae['caput'][clavis_normationi] and \
neo_caput in self.methodus_ex_tabulae['caput'][clavis_normationi] and \
self.methodus_ex_tabulae['caput'][clavis_normationi][neo_caput]:
forma = self.methodus_ex_tabulae['caput'][clavis_normationi][neo_caput]

hxl_hashtag = forma.replace(
'{{caput_clavi_normali}}', clavis_normationi)

return hxl_hashtag

# def clavis_ad_hxl(self, clavis: str) -> str:
# pass


def numerordinatio_neo_separatum(
numerordinatio: str, separatum: str = "_") -> str:
resultatum = ''
Expand Down
Loading

0 comments on commit a38ac83

Please sign in to comment.