Skip to content

Commit

Permalink
999999999_7200235.py (#39): hxltm_carricato__cod_ab_levels_ttl() impr…
Browse files Browse the repository at this point in the history
…oved
  • Loading branch information
fititnt committed May 25, 2022
1 parent 5c47fb9 commit bf8e088
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 12 deletions.
41 changes: 34 additions & 7 deletions officina/999999999/0/999999999_7200235.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
# hxltm_sine_columnis,
hxltm_ex_selectis,
hxltm_index_praeparationi,
numerordinatio_descendentibus,
numerordinatio_progenitori,
qhxl_hxlhashtag_2_bcp47,
HXLTMAdRDFSimplicis,
Expand Down Expand Up @@ -1086,7 +1087,7 @@ def hxltm_carricato__cod_ab_levels(


def hxltm_carricato__cod_ab_levels_ttl(
caput: list, data: list, numerordinatio_praefixo: str = '1603_45_16'
caput: list, data: list, numerordinatio_praefixo: str = '1603:45:16'
) -> list:
"""hxltm_carricato__cod_ab_levels filter cod_ab_index into a list of levels
Expand All @@ -1100,17 +1101,43 @@ def hxltm_carricato__cod_ab_levels_ttl(
"""
paginae = []

print('caput', caput)
# note, on this case, we get an list already with only the root
# items, so we have to deal with

# https://www.wikidata.org/wiki/EntitySchema:E49

# paginae.append('# [{0}]'.format(
# numerordinatio_progenitori(numerordinatio_praefixo, ':')))
# paginae.append('@prefix skos: <http://www.w3.org/2004/02/skos/core#> .')
basi = numerordinatio_neo_separatum(numerordinatio_praefixo, ':')


# <urn:1603:63:101> a skos:ConceptScheme ;
# skos:prefLabel "1603:63:101"@mul-Zyyy-x-n1603 .

# for linea in data:
# paginae.append('<urn:{0}>'.format(linea[0]))
collectio = map(lambda x: x[0], data)
collectio_sine_ordo = set(map(
lambda x: numerordinatio_progenitori(x, ':'), collectio))
# print(collectio_sine_ordo)

paginae.append('# [{0}]'.format(basi))
paginae.append('@prefix skos: <http://www.w3.org/2004/02/skos/core#> .')
paginae.append('')
paginae.append("<urn:{0}> a skos:ConceptScheme ; \n"
" skos:prefLabel \"{0}\"@mul-Zyyy-x-n1603 .".format(
basi))
paginae.append(" skos:hasTopConcept\n {0} .".format(
" ,\n ".join(map(lambda x: f'<urn:{x}>', collectio_sine_ordo ))
))
for linea in data:
progenitori = numerordinatio_progenitori(linea[0], ':')
descendentibus = numerordinatio_descendentibus(
progenitori, collectio, 1)
# paginae.append('<urn:{0}>'.format(linea[0]))
# paginae.append(' # {0}'.format(str(linea)))
# <urn:1603:45:16:76:0>
# # ['1603:45:16:76:0', '76', 0, 'BRA', 'BR']
# <urn:1603:45:16:76:1>
# # ['1603:45:16:76:1', '76', 1, 'BRA', 'BR']
# <urn:1603:45:16:76:2>
# # ['1603:45:16:76:2', '76', 2, 'BRA', 'BR']

return paginae

Expand Down
48 changes: 43 additions & 5 deletions officina/999999999/0/L999999999_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,9 +670,9 @@ def praeparatio_identitas_locali(self):
if pcode_index is None:
raise SyntaxError(
'{0} not in (hxltm)<{1}>/(hxl)<{2}>(csv){3}'.format(
pcode_hashtag, self.caput_hxltm,
self.caput_hxl, self.caput_originali
))
pcode_hashtag, self.caput_hxltm,
self.caput_hxl, self.caput_originali
))
# pcode_index = self.caput_hxltm.index(pcode_hashtag)

self.caput_hxltm.insert(0, '#item+conceptum+codicem')
Expand All @@ -688,8 +688,8 @@ def praeparatio_identitas_locali(self):
# Ex. 31 ad BR31
pcode_numeri = pcode_completo.replace(self.pcode_praefixo, '')

## Ex: Haiti admin3Pcode HT0111-01, HT0111-02, HT0111-03
pcode_numeri = re.sub('[^0-9]','', pcode_numeri)
# Ex: Haiti admin3Pcode HT0111-01, HT0111-02, HT0111-03
pcode_numeri = re.sub('[^0-9]', '', pcode_numeri)

try:
linea_novae.append(int(pcode_numeri))
Expand Down Expand Up @@ -2832,6 +2832,44 @@ def qhxl_hxlhashtag_2_bcp47(
return bcp47_simplici


def numerordinatio_descendentibus(
numerordinatio: str, collectio: list, ordo_maximo: int = None) -> list:
"""numerordinatio_descendentibus _summary_
Trivia:
- collēctiō, s, f, , nominativus
- dēscendentibus, pl, m/f/n, , dativus,
https://en.wiktionary.org/wiki/descendens#Latin
- ōrdō, s, m, nominativus, https://en.wiktionary.org/wiki/ordo#Latin
- ōrdinī, s, m, dativus,
- maximō, s, m/n, dativus, https://en.wiktionary.org/wiki/maximus#Latin
Args:
numerordinatio (str): _description_
collectio (list): _description_
ordo_maximo (int, optional): _description_. Defaults to None.
Returns:
list: _description_
"""

resultatum = []

if ordo_maximo is not None:
ordo_maximo = ordo_maximo + numerordinatio_ordo(numerordinatio)

for item in collectio:
if item.startswith(numerordinatio) and item != numerordinatio:
if ordo_maximo is None:
resultatum.append(item)
else:
item_ordini = numerordinatio_ordo(item)
if item_ordini <= ordo_maximo:
resultatum.append(item)

return resultatum


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

0 comments on commit bf8e088

Please sign in to comment.