Skip to content

Commit

Permalink
(#37) bcp47_rdf_extension_caput_ad_columnae_i() draft
Browse files Browse the repository at this point in the history
  • Loading branch information
fititnt committed Jun 28, 2022
1 parent fbbcebd commit 4014f6b
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
2 changes: 1 addition & 1 deletion officina/999999999/0/1603_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -6018,7 +6018,7 @@ def execute_cli(self, pyargs, stdin=STDIN, stdout=sys.stdout,
# return self.output(tabulam_numerae)
return self.output(quod_query)

print('unknow option.')
print('unknow option. --help ?')
return self.EXIT_ERROR

def output(self, output_collectiom):
Expand Down
6 changes: 6 additions & 0 deletions officina/999999999/0/999999999_54872.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@
999999999/1568346/data/hxlstandard-rdf-namespaces-example.hxl.csv \
999999999/1568346/data/unesco-thesaurus.bcp47g.tsv
{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 \
--numerordinatio-cum-antecessoribus \
--rdf-ontologia-ordinibus=5 --rdf-trivio=5002
(Data operations)
{0} --objectivum-formato=_temp_bcp47 \
--punctum-separato-de-fontem=$'\\t' \
Expand Down
43 changes: 41 additions & 2 deletions officina/999999999/0/L999999999_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -1776,14 +1776,41 @@ def bcp47_rdf_extension(
return result


def bcp47_rdf_extension_caput_ad_columnae_i(
caput_originali: List[str],
caput_originali_asa: List[str],
namespaces: List[dict] = None,
strictum: bool = True
) -> dict:
resultatum = []
extras = []
for index in range(len(caput_originali)):
_hxl_minimal = caput_originali_asa[index]['_callbacks']['hxl_minimal']
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])
# print(caput_originali_asa[index])
# break
# return caput_originali
return resultatum


def bcp47_rdf_extension_relationship(
header: List[str],
namespaces: List[dict] = None,
strictum: bool = True
) -> dict:
"""""Metadata processing of the bcp47_rdf_extension version
_extended_summary_
Note about caput_ad_columnae_i:
- We can generate an ASA about how would be if long column names
would be renamed and added as text value, (e.g. do it from a
wide dataset), but not designed to do it from narrow dataset
Args:
caput (List[str]): _description_
Expand All @@ -1792,10 +1819,17 @@ def bcp47_rdf_extension_relationship(
Returns:
dict: _description_
"""
# About caput_**, see
# - https://en.wikipedia.org/wiki/Wide_and_narrow_data
# - https://tidyr.tidyverse.org/
# - pandas.pydata.org/pandas-docs/stable/reference/api/pandas.melt.html
# - pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.pivot.html

# @TODO: this function is obviously doing too much at once. Eventually
# can be refactored. (rocha, 2022-06-09 10:50 UTC)
result = {
'caput_originali': header,
'caput_ad_columnae_i': [],
'caput_originali_asa': [],
# 'rdf:subject': None,
# 'rdf:predicate': [],
Expand Down Expand Up @@ -1943,7 +1977,8 @@ def _aux_recalc_containers(result: dict) -> dict:
# ========= Fist iteration over each column, START =========
for index, item in enumerate(header):
item_meta = bcp47_langtag(
item, ['language', 'script', 'extension'], strictum=False)
item, ['language', 'script', 'extension', '_callbacks'],
strictum=False)
# @TODO; get erros and export them to upper level
# item_meta['_column'] = index
item_meta['_index_ex_tabula'] = index
Expand Down Expand Up @@ -2130,6 +2165,10 @@ def _aux_recalc_containers(result: dict) -> dict:

result = _aux_recalc_containers(result)

result['caput_ad_columnae_i'] = bcp47_rdf_extension_caput_ad_columnae_i(
result['caput_originali'],
result['caput_originali_asa'])

return result


Expand Down
2 changes: 2 additions & 0 deletions officina/999999999/0/frictionless_to_sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@
--data-apothecae-ex-praefixis='1603,!1603_45_46' \
> ./datapackage.json
# ex-praefixis='1603_16,1603_45_16,!1603_45_76,!1603_16_76,!1603_45_49'
(Use jq to print resources)
jq .resources[].name < datapackage.json
Expand Down

0 comments on commit 4014f6b

Please sign in to comment.