Skip to content

Commit

Permalink
1603_45_16.lib.sh (#45): bootstrap_1603_16_1__lsf works
Browse files Browse the repository at this point in the history
  • Loading branch information
fititnt committed Jul 23, 2022
1 parent b764406 commit e901a44
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 24 deletions.
17 changes: 15 additions & 2 deletions officina/999999999/0/L999999999_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ def _expand_hxl_ad_rdf():
# 'p': 'http://www.wikidata.org/prop/',
'wdt': 'http://www.wikidata.org/prop/direct/',
'wdv': 'http://www.wikidata.org/value/',
'p': 'http://www.wikidata.org/prop/', # NOTE: preffer wdata for datasets
'p': 'http://www.wikidata.org/prop/', # NOTE: preffer use wdata for datasets
}
# For "Base OWL" of Wikidata, download link: http://wikiba.se/ontology

Expand Down Expand Up @@ -1060,7 +1060,7 @@ def _expand_hxl_ad_rdf():
'obo:locationofatsometime': 'obo:BFO_0000124',
'obo:bfo124': 'obo:BFO_0000124',
}
# Note: prefixes that already are lower case do not be here
# Note: prefixes that already are lower case should not be here
RDF_SPATIA_NOMINALIBUS_PREFIX_EXTRAS = {
}

Expand All @@ -1071,6 +1071,7 @@ def _expand_hxl_ad_rdf():

def _rdf_spatia_nominalibus_prefix_normali(rem: str) -> dict:
# exemplum: obo:bfo29 -> obo:BFO_0000029
# exemplum: wdata:p2082 -> wdata:P2082
rem_l = rem.lower()
if rem_l in RDF_SPATIA_NOMINALIBUS_PREFIX:
return RDF_SPATIA_NOMINALIBUS_PREFIX[rem_l]
Expand All @@ -1084,6 +1085,10 @@ def _rdf_spatia_nominalibus_prefix_normali(rem: str) -> dict:
rem_item_alpha = rem_ls.replace(rem_digits, '').upper()
rem_digits_full = rem_digits.zfill(7)
return 'obo:{0}_{1}'.format(rem_item_alpha, rem_digits_full)
if rem_l.startswith('wdata:'):
rem_ls = rem_l.replace('wdata:', '')
rem_item_alpha = rem_ls.upper()
return 'wdata:{0}'.format(rem_item_alpha)

# Worst case: assume input already is normalized
return rem
Expand Down Expand Up @@ -2589,6 +2594,10 @@ def bcp47_rdf_extension_poc(
'_error': [],
}

# Enforce normalization for Wikidata predicates, we apply
# _rdf_spatia_nominalibus_prefix_normali()
_to_upper = ['wdata']

if not rdf_sine_spatia_nominalibus or len(rdf_sine_spatia_nominalibus) == 0:
rdf_sine_spatia_nominalibus = None

Expand Down Expand Up @@ -2751,6 +2760,10 @@ def _helper_aux_triple(

_temp1, _temp2 = predicate_and_subject.split('||')
predicate = _temp1
for _item in _to_upper:
if predicate.startswith(_item + ':'):
predicate = _rdf_spatia_nominalibus_prefix_normali(
predicate)

if value_separator is not None and \
object_literal.find(value_separator) > -1 and \
Expand Down
61 changes: 39 additions & 22 deletions officina/999999999/1603_45_16.lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ bootstrap_1603_16_1__lsf() {
objetivum_archivum_no11="${ROOTDIR}/1603/16/1/0/$_nomen.no11.tm.hxl.csv"
objetivum_archivum_no11_bcp47min="${ROOTDIR}/1603/16/1/0/$_nomen.no11.bcp47.csv"
objetivum_archivum_no11_skos="${ROOTDIR}/1603/16/1/0/$_nomen.no11.skos.ttl"
objetivum_archivum_datapackage="${ROOTDIR}/1603/16/1/0/datapackage.json"

opus_temporibus_temporarium="${DESTDIR}/999999/0/${_nomen}~TEMP~1.csv"
opus_temporibus_temporarium_2="${DESTDIR}/999999/0/${_nomen}~TEMP~2.csv"
Expand Down Expand Up @@ -187,37 +188,39 @@ bootstrap_1603_16_1__lsf() {
file_update_if_necessary "csv" "${fontem_archivum_temporarium_no11}" "${objetivum_archivum_no11}"
file_update_if_necessary "csv" "${fontem_archivum_temporarium_no1}" "${objetivum_archivum_no1}"

## Computational-like RDF serialization, "OWL version" --------------------
# @TODO fix generation of invalid format if
# --rdf-sine-spatia-nominalibus=skos,devnull is enabled
rdf_ontologia_ordinibus='4'
rdf_trivio='5000'
set -x

## Computational-like RDF serialization, "OWL version" --------------------
# @TODO fix generation of invalid format if
# --rdf-sine-spatia-nominalibus=skos,devnull is enabled
"${ROOTDIR}/999999999/0/999999999_54872.py" \
--methodus=_temp_no1 \
--numerordinatio-cum-antecessoribus \
--rdf-sine-spatia-nominalibus=devnull \
--rdf-ontologia-ordinibus="${rdf_ontologia_ordinibus}" \
--rdf-trivio="${rdf_trivio}" \
<"${objetivum_archivum_no1}" >"${opus_temporibus_temporarium_ttl_1}"

# "${ROOTDIR}/999999999/0/999999999_54872.py" \
# --methodus=_temp_no1 \
# --numerordinatio-cum-antecessoribus \
# --rdf-sine-spatia-nominalibus=devnull \
# --rdf-ontologia-ordinibus="${rdf_ontologia_ordinibus}" \
# --rdf-trivio="${rdf_trivio}" \
# <"${objectivum_archivum_no1}" >"${opus_temporibus_temporarium}"
rdfpipe --input-format=turtle --output-format=longturtle \
"${opus_temporibus_temporarium_ttl_1}" \
>"${opus_temporibus_temporarium_ttl_2}"

# # rapper --quiet --input=turtle --output=turtle \
# # "${opus_temporibus_temporarium}" \
# # >"${objectivum_archivum_no1_owl_ttl}"
riot --validate "${opus_temporibus_temporarium_ttl_2}"

# rdfpipe --input-format=turtle --output-format=longturtle \
# "${opus_temporibus_temporarium}" \
# >"${objectivum_archivum_no1_owl_ttl}"
# sleep 10
set +x

# riot --validate "${objectivum_archivum_no1_owl_ttl}"
file_update_if_necessary "ttl" "${opus_temporibus_temporarium_ttl_2}" "${objetivum_archivum_no1_owl}"

## Linguistic-like RDF serialization, "SKOS version" ----------------------
## Linguistic-like RDF serialization, "SKOS version" ------------------------
# @TODO fix invalid generation if disabling OWL with
# --rdf-sine-spatia-nominalibus=owl

rdf_ontologia_ordinibus='4'
rdf_trivio='5000'

set -x
"${ROOTDIR}/999999999/0/999999999_54872.py" \
--methodus=_temp_no1 \
--numerordinatio-cum-antecessoribus \
Expand All @@ -226,16 +229,30 @@ bootstrap_1603_16_1__lsf() {
--rdf-trivio="${rdf_trivio}" \
<"${objetivum_archivum_no11}" >"${opus_temporibus_temporarium_ttl_1}"

rdfpipe --input-format=turtle --output-format=longturtle \
"${opus_temporibus_temporarium_ttl_1}" \
>"${opus_temporibus_temporarium_ttl_2}"
rdfpipe --input-format=turtle --output-format=longturtle \
"${opus_temporibus_temporarium_ttl_1}" \
>"${opus_temporibus_temporarium_ttl_2}"

riot --validate "${opus_temporibus_temporarium_ttl_2}"

set +x

# file_update_if_necessary "ttl" "${opus_temporibus_temporarium_ttl_2}" "${objetivum_archivum_no1_owl}"
file_update_if_necessary "ttl" "${opus_temporibus_temporarium_ttl_2}" "${objetivum_archivum_no11_skos}"

## Now create the packages ---------------------------------------------------

set -x
"${ROOTDIR}/999999999/0/1603_1.py" \
--methodus='data-apothecae-unicae' \
--data-apothecae-ex='1603_16_1_0' \
--data-apothecae-ad-stdout \
--data-apothecae-formato='datapackage' \
>"$objetivum_archivum_datapackage"

frictionless validate "$objetivum_archivum_datapackage"

set +x
}

#######################################
Expand Down

0 comments on commit e901a44

Please sign in to comment.