Skip to content

Commit

Permalink
999999999_54872.py (#37) draft of header naming shortener (to cope wi…
Browse files Browse the repository at this point in the history
…th databases massive imports)
  • Loading branch information
fititnt committed Jun 28, 2022
1 parent 4014f6b commit 424347a
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ officina/1603/1603.statum.yml
!officina/999999999/1568346/data/cod-ab-example1.bcp47.tsv
# !officina/999999999/1568346/data/cod-ab-example2.bcp47.tsv
!officina/999999999/1568346/data/cod-ab-example1-with-inferences.bcp47.tsv
!officina/999999999/1568346/data/cod-ab-example1-with-inferences.no1.hxl.tm.tsv
!officina/999999999/1568346/data/cod-ab-example1-with-inferences.no1.tm.hxl.tsv
!officina/999999999/1568346/data/hxlstandard-rdf-namespaces-hardcoded.hxl.csv
!officina/999999999/1568346/data/hxlstandard-rdf-namespaces-example.hxl.csv
# /officina/README.md
Expand Down
69 changes: 67 additions & 2 deletions officina/999999999/0/999999999_54872.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
# ==============================================================================
# /opt/Protege-5.5.0/run.sh

import csv
import json
import sys
import os
Expand Down Expand Up @@ -119,7 +120,7 @@
{0} --objectivum-formato=_temp_hxl_meta_in_json \
--punctum-separato-de-fontem=$'\\t' \
999999999/1568346/data/cod-ab-example1-with-inferences.no1.hxl.tm.tsv \
999999999/1568346/data/cod-ab-example1-with-inferences.no1.tm.hxl.tsv \
--numerordinatio-cum-antecessoribus \
--rdf-ontologia-ordinibus=5 --rdf-trivio=5002
Expand Down Expand Up @@ -163,7 +164,7 @@
(Data operations, header conversion RDF+HXL -> RDF+BCP47)
varhxl=$(head -n1 \
999999999/1568346/data/cod-ab-example1-with-inferences.no1.hxl.tm.tsv)
999999999/1568346/data/cod-ab-example1-with-inferences.no1.tm.hxl.tsv)
{0} --objectivum-formato=_temp_header_hxl_to_bcp47 "$varhxl"
(Data operations, header conversion RDF+BCP47 -> RDF+HXL)
Expand Down Expand Up @@ -301,6 +302,8 @@ def make_args(self, hxl_output=True):
'_temp_hxl_meta_in_json',
'_temp_header_hxl_to_bcp47',
'_temp_header_bcp47_to_hxl',
'_temp_bcp47_to_bcp47_shortnames',
'_temp_no1_to_no1_shortnames',
],
# required=True
default='application/x-turtle'
Expand Down Expand Up @@ -457,6 +460,47 @@ def execute_cli(self, pyargs, stdin=STDIN, stdout=sys.stdout,
# print(RDF_SPATIA_NOMINALIBUS_EXTRAS)
# pass

if pyargs.objectivum_formato in [
'_temp_bcp47_to_bcp47_shortnames',
'_temp_no1_to_no1_shortnames']:
# if pyargs.objectivum_formato = '_temp_no1_to_no1_shortnames':

if _stdin:
raise NotImplementedError('{0} not with stdin'.format(
pyargs.objectivum_formato))

caput, data = hxltm_carricato_brevibus(
_infile, _stdin, punctum_separato=fontem_separato)

if pyargs.objectivum_formato == '_temp_no1_to_no1_shortnames':
caput_novo = []
for _item in caput:
# print('hxl item > ', _item)
_hxl = HXLHashtagSimplici(_item).praeparatio()
_item_bcp47 = _hxl.quod_bcp47(strictum=False)
# print('_item_bcp47 > ', _item_bcp47)
caput_novo.append(_item_bcp47)
caput = caput_novo
# print('caput', caput)

rdf_sine_spatia_nominalibus = pyargs.rdf_sine_spatia_nominalibus
if not rdf_sine_spatia_nominalibus:
rdf_sine_spatia_nominalibus = []
rdf_sine_spatia_nominalibus.append('devnull')

meta = bcp47_rdf_extension_poc(
caput, data, objective_bag=pyargs.rdf_bag,
rdf_sine_spatia_nominalibus=rdf_sine_spatia_nominalibus,
cum_antecessoribus=pyargs.cum_antecessoribus,
rdf_ontologia_ordinibus=pyargs.rdf_ontologia_ordinibus,
est_meta=True)

no1_to_no1_shortnames(
meta, _infile, punctum_separato=fontem_separato)

return self.EXIT_OK
pass

# @TODO maybe refactor this temporary part
# if pyargs.objectivum_formato == '_temp_bcp47_meta_in_json':
if pyargs.objectivum_formato in [
Expand Down Expand Up @@ -807,6 +851,27 @@ def actio(self):
# print('failed')


def no1_to_no1_shortnames(
caput_asa, fontem, punctum_separato=","
):

# csv_imprimendo()
with open(fontem, 'r') as _fons:
_writer = csv.writer(sys.stdout, delimiter=punctum_separato)
_csv_reader = csv.reader(_fons, delimiter=punctum_separato)
for linea in _csv_reader:
_writer.writerow(linea)
# pass
# if len(caput) == 0:
# # caput = linea
# # _reader_caput = csv.reader(linea)
# # _gambi = [linea, linea]
# # _reader_caput = csv.reader(_gambi)
# # caput = next(_reader_caput)
# caput = linea
# pass


def numerordinatio_neo_separatum(
numerordinatio: str, separatum: str = "_") -> str:
resultatum = ''
Expand Down
15 changes: 11 additions & 4 deletions officina/999999999/0/L999999999_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -1789,14 +1789,21 @@ def bcp47_rdf_extension_caput_ad_columnae_i(
if not _hxl_minimal:
resultatum.append(caput_originali[index])
else:
resultatum.append(caput_originali[index])
resultatum.append(_hxl_minimal[0])
extras.append(_hxl_minimal)
# resultatum.append(caput_originali[index])
resultatum.append(caput_originali_asa[index])
_meta = hxl_hashtag_to_bcp47('#item' + _hxl_minimal[0])
resultatum.append(_meta['Language-Tag_normalized'])
extras.append([
_meta['Language-Tag_normalized'] + '-x-hxlattrs',
_hxl_minimal[1]
])
# resultatum.append(caput_originali[index])
# resultatum.append(caput_originali_asa[index])
# print(caput_originali_asa[index])
# break
# return caput_originali
if len(extras):
resultatum.extend(extras)

return resultatum


Expand Down
12 changes: 12 additions & 0 deletions officina/999999999/1603_45_16.sh
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,18 @@ deploy_1603_45_16_global_admX_unicum
# ./999999999/0/999999999_7200235.py --methodus=xlsx_ad_csv --ordines=1 999999/1603/45/16/xlsx/ago.xlsx
# cat 999999/1603/45/16/csv/AGO_1.csv

# ./999999999/0/linguacodex.py --de_hxl_simplex --de_bcp47_simplex --de_codex=qcc-Zxxx-r-sU2200-s1-snop-pSKOS-prelated-ps2-x-wikip12 | jq

# ./999999999/0/linguacodex.py --de_hxl_simplex --de_hxlhashtag='#item+i_qcc+is_zxxx+rdf_p_skos_broader_s2+rdf_s_u2203_s2+rdf_t_xsd_datetime+rdf_y_u0002_unescothes+rdf_y_u001d_u007c' | jq

## Collection of items

# ./999999999/0/999999999_54872.py --objectivum-formato=_temp_bcp47_meta_in_json --punctum-separato-de-fontem=$'\t' 999999999/1568346/data/cod-ab-example1-with-inferences.bcp47.tsv --numerordinatio-cum-antecessoribus --rdf-ontologia-ordinibus=5 --rdf-trivio=5002 | jq

# ./999999999/0/999999999_54872.py --objectivum-formato=_temp_hxl_meta_in_json --punctum-separato-de-fontem=$'\t' 999999999/1568346/data/cod-ab-example1-with-inferences.no1.tm.hxl.tsv --numerordinatio-cum-antecessoribus --rdf-ontologia-ordinibus=5 --rdf-trivio=5002 | jq

# ./999999999/0/999999999_54872.py --objectivum-formato=_temp_hxl_meta_in_json --punctum-separato-de-fontem=$'\t' 999999999/1568346/data/cod-ab-example1-with-inferences.no1.tm.hxl.tsv --numerordinatio-cum-antecessoribus --rdf-ontologia-ordinibus=5 --rdf-trivio=5002 | jq .caput_asa.caput_ad_columnae_i

#---- csv
# ./999999999/0/999999999_7200235.py --methodus=xlsx_ad_csv --ordines=0 999999/1603/45/16/xlsx/ago.xlsx > 999999/0/ago_0.csv
# csv-diff 999999/1603/45/16/csv/AGO_0.csv 999999/0/ago_0.csv
Expand Down

0 comments on commit 424347a

Please sign in to comment.