Skip to content

Commit

Permalink
999999999_7200235.py (#2): #country+code+v_iso3166p1a2
Browse files Browse the repository at this point in the history
  • Loading branch information
fititnt committed Jun 29, 2022
1 parent ca86756 commit 092d259
Show file tree
Hide file tree
Showing 3 changed files with 187 additions and 6 deletions.
12 changes: 6 additions & 6 deletions officina/999999999/0/L999999999_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,11 @@
'__no1bpc47__': 'qcc-Zxxx-r-aOBO-abfo29-anop-sU2200-s5000-snop-pOBO-pbfo124-ps5001',
'__no1hxl__': '#item+rem+i_qcc+is_zxxx+rdf_a_obo_bfo29+rdf_p_obo_bfo124_s5001+rdf_s_u2200_s5000'
},
# # P297 ISO 3166-1 alpha-2 code, https://www.wikidata.org/wiki/Property:P297
# '#country+code+v_iso3166p1a2': {
# '__no1bpc47__': 'qcc-Zxxx-r-pWDATA-pq7200235-ps5001-x-wdataq7200235',
# '__no1hxl__': '#item+rem+i_qcc+is_zxxx+ix_wdataq7200235+rdf_p_wdata_q7200235_s5001'
# },
# P297 ISO 3166-1 alpha-2 code, https://www.wikidata.org/wiki/Property:P297
'#country+code+v_iso3166p1a2': {
'__no1bpc47__': 'qcc-Zxxx-r-pP-pp297-ps5000-x-p297',
'__no1hxl__': '#item+rem+i_qcc+is_zxxx+ix_p297+rdf_p_p_p297_s5000'
},
'#adm1+code+v_numerodinatio': {
'__no1bpc47__': 'qcc-Zxxx-r-aOBO-abfo29-anop-sU2200-s5001-snop-pOBO-pbfo124-ps5002-pOBO-pbfo171-ps5000',
'__no1hxl__': '#item+rem+i_qcc+is_zxxx+rdf_a_obo_bfo29+rdf_p_obo_bfo124_s5002+rdf_p_obo_bfo171_s5000+rdf_s_u2200_s5001'
Expand Down Expand Up @@ -1442,7 +1442,7 @@ def bcp47_langtag_callback_hxl_minimal(

# raise ValueError(res)

# We only try to compact concepts
# We only try to compact interlingual concepts, not linguistic
if not res.startswith('+i_qcc+is_zxxx'):
return None

Expand Down
171 changes: 171 additions & 0 deletions officina/999999999/1603_45_16.lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,177 @@ bootstrap_1603_45_16__item_no1() {
printf "\t%40s\n" "${tty_green}${FUNCNAME[0]} FINISHED OKAY ${tty_normal}"
}

#######################################
# Convert the XLSXs to intermediate formats on 999999/1603/45/16 using
# 999999999_7200235.py to 1603/45/16/{cod_ab_level}/
#
# @TODO: potentially use more than one source (such as IGBE data for BRA)
# instead of direclty from OCHA
#
# Globals:
# ROOTDIR
# DESTDIR
#
# Arguments:
# numerordinatio_praefixo
# unm49
# iso3661p1a3
# pcode_praefixo
# cod_ab_level_max
# est_temporarium_fontem
# est_temporarium_objectivum
# rdf_ontologia_ordinibus (Tip: "5" if prefix 1603_45_16, "4" if 1603_16)
#
# Outputs:
# Convert files
#######################################
bootstrap_1603_45_16__item_bcp47() {
numerordinatio_praefixo="$1"
unm49="${2}"
iso3661p1a3="${3}"
pcode_praefixo="${4}"
cod_ab_level_max="${5}"
est_temporarium_fontem="${6:-"1"}"
est_temporarium_objectivum="${7:-"0"}"
rdf_ontologia_ordinibus="${8:-"5"}"

if [ "$est_temporarium_fontem" -eq "1" ]; then
_basim_fontem="${ROOTDIR}/999999"
else
_basim_fontem="${ROOTDIR}"
fi
if [ "$est_temporarium_objectivum" -eq "1" ]; then
_basim_objectivum="${DESTDIR}/999999"
else
_basim_objectivum="${DESTDIR}"
fi

# 1603_45_16 -> 1603/45/16
__group_path=$(numerordinatio_neo_separatum "$numerordinatio_praefixo" "/")

_iso3661p1a3_lower=$(echo "$iso3661p1a3" | tr '[:upper:]' '[:lower:]')

fontem_archivum="${_basim_fontem}/1603/45/16/xlsx/${_iso3661p1a3_lower}.xlsx"
# objectivum_archivum_basi="${_basim_objectivum}/1603/45/16/${unm49}"
objectivum_archivum_basi="${_basim_objectivum}/${__group_path}/${unm49}"
# opus_temporibus_temporarium="${ROOTDIR}/999999/0/${unm49}~lvl.tsv"
opus_temporibus_temporarium="${DESTDIR}/999999/0/${unm49}~1.ttl"
opus_temporibus_temporarium_2="${DESTDIR}/999999/0/${unm49}~2.ttl"

printf "\t%40s\n" "${tty_blue}${FUNCNAME[0]} STARTED [$numerordinatio_praefixo] [$unm49] [$iso3661p1a3] [$pcode_praefixo]${tty_normal}"

echo "TODO this is just a draft. please implement me later"
return 0

# for file_path in "${ROOTDIR}"/999999/1603/45/16/xlsx/*.xlsx; do
# ISO3166p1a3_original=$(basename --suffix=.xlsx "$file_path")
# ISO3166p1a3=$(echo "$ISO3166p1a3_original" | tr '[:lower:]' '[:upper:]')
# UNm49=$(numerordinatio_codicem_locali__1603_45_49 "$ISO3166p1a3")

# if [ ! -d "$objectivum_archivum_basi" ]; then
# mkdir "$objectivum_archivum_basi"
# fi

# file_xlsx="${ISO3166p1a3_original}.xlsx"

echo "cod_ab_levels $cod_ab_level_max"

for ((i = 0; i <= cod_ab_level_max; i++)); do
cod_level="$i"
if [ "$_iso3661p1a3_lower" == "bra" ] && [ "$cod_level" == "2" ]; then
echo ""
echo "Skiping COD-AB-BR lvl 2"
echo ""
continue
fi

objectivum_archivum_basi_lvl="${objectivum_archivum_basi}/${cod_level}"
# objectivum_archivum_no1="${objectivum_archivum_basi_lvl}/${numerordinatio_praefixo}_${unm49}_${cod_level}.no1.tm.hxl.csv"
objectivum_archivum_no1="${objectivum_archivum_basi_lvl}/${numerordinatio_praefixo}_${unm49}_${cod_level}.no1.tm.hxl.csv"

objectivum_archivum_no1_owl_ttl="${objectivum_archivum_basi_lvl}/${numerordinatio_praefixo}_${unm49}_${cod_level}.no1.owl.ttl"
objectivum_archivum_no1_skos_ttl="${objectivum_archivum_basi_lvl}/${numerordinatio_praefixo}_${unm49}_${cod_level}.no1.skos.ttl"

# set -x
# rm "$objectivum_archivum_no1" || true
# set +x
# continue
echo " cod-ab-$_iso3661p1a3_lower-$cod_level [$objectivum_archivum_no1] ..."
# if [ ! -d "$objectivum_archivum_basi_lvl" ]; then
# mkdir "$objectivum_archivum_basi_lvl"
# fi

# echo "TODO"

rdf_trivio=$((5000 + cod_level))

## 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" \
# --objectivum-formato=_temp_no1 \
# --numerordinatio-cum-antecessoribus \
# --rdf-sine-spatia-nominalibus=skos,devnull \
# --rdf-ontologia-ordinibus="${rdf_ontologia_ordinibus}" \
# --rdf-trivio="${rdf_trivio}" \
# <"${objectivum_archivum_no1}" >"${opus_temporibus_temporarium}"

"${ROOTDIR}/999999999/0/999999999_54872.py" \
--objectivum-formato=_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}"

rapper --quiet --input=turtle --output=turtle \
"${opus_temporibus_temporarium}" \
>"${objectivum_archivum_no1_owl_ttl}"

riot --validate "${objectivum_archivum_no1_owl_ttl}"

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

# "${ROOTDIR}/999999999/0/999999999_54872.py" \
# --objectivum-formato=_temp_no1 \
# --numerordinatio-cum-antecessoribus \
# --rdf-sine-spatia-nominalibus=owl,obo,p,geo,devnull \
# --rdf-ontologia-ordinibus="${rdf_ontologia_ordinibus}" \
# --rdf-trivio="${rdf_trivio}" \
# <"${objectivum_archivum_no1}" >"${opus_temporibus_temporarium_2}"

"${ROOTDIR}/999999999/0/999999999_54872.py" \
--objectivum-formato=_temp_no1 \
--numerordinatio-cum-antecessoribus \
--rdf-sine-spatia-nominalibus=obo,p,geo,devnull \
--rdf-ontologia-ordinibus="${rdf_ontologia_ordinibus}" \
--rdf-trivio="${rdf_trivio}" \
<"${objectivum_archivum_no1}" >"${opus_temporibus_temporarium_2}"

rapper --quiet --input=turtle --output=turtle \
"${opus_temporibus_temporarium_2}" \
>"${objectivum_archivum_no1_skos_ttl}"

riot --validate "${objectivum_archivum_no1_skos_ttl}"
set +x

echo "OWL TTL: [${objectivum_archivum_no1_owl_ttl}]"
echo "SKOS TTL: [${objectivum_archivum_no1_skos_ttl}]"

rm "$opus_temporibus_temporarium"
rm "$opus_temporibus_temporarium_2"

done

# return 0
# done
printf "\t%40s\n" "${tty_green}${FUNCNAME[0]} FINISHED OKAY ${tty_normal}"
}

#######################################
# Convert the XLSXs to intermediate formats on 999999/1603/45/16 using
# 999999999_7200235.py to 1603/45/16/{cod_ab_level}/
Expand Down
10 changes: 10 additions & 0 deletions officina/999999999/1603_45_16.sh
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,16 @@ __temp_download_external_cod_data() {
# __temp_preproces_quicktest_1603_16_24
# exit 0

# unm49=68
# v_iso3="COL"
# v_iso2="CO"
# cod_ab_level_max=3
# bootstrap_1603_45_16__item_bcp47 "1603_16" "${unm49}" "$v_iso3" "$v_iso2" "$cod_ab_level_max" "1" "0" "4"

# exit 0

# exit 0

# bootstrap_1603_45_16__all "1603_45_16"
# bootstrap_999999_1603_45_16_neo ""
# bootstrap_999999_1603_45_16_neo "BRA"
Expand Down

0 comments on commit 092d259

Please sign in to comment.