Skip to content

Commit

Permalink
#3, #9: MVP of merging Wikidata translations on Numerordinatio dictio…
Browse files Browse the repository at this point in the history
…naries
  • Loading branch information
fititnt committed Jan 30, 2022
1 parent f3c6136 commit 9e43101
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 19 deletions.
4 changes: 4 additions & 0 deletions officinam/999999999/0/1603_3_12.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ def query(self):

# select = ['(?item AS ?item__conceptum__codicem)']
select = ['(STRAFTER(STR(?item), "entity/") AS ?item__conceptum__codicem)']
# select = [
# '(STRAFTER(STR(?item), "entity/") AS ?item__conceptum__codicem)',
# '(STRAFTER(STR(?item), "entity/") AS ?item__rem__i_qcc__is_zxxx__ix_wikiq)'
# ]
filter_otional = []
for pair in self.D1613_1_51_langpair:
select.append('?' + pair[1])
Expand Down
2 changes: 2 additions & 0 deletions officinam/999999999/1603_17.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ neo_codex_de_numerordinatio "1603_3_12_6" "0" "0"
file_download_if_necessary "$DATA_1603_25_1" "1603_25_1" "csv" "tm.hxl.csv" "hxltmcli" "1"
file_convert_numerordinatio_de_hxltm "1603_25_1" "1" "0"
neo_codex_de_numerordinatio "1603_25_1" "0" "0"
file_translate_csv_de_numerordinatio_q "1603_25_1" "0" "0"
file_merge_numerordinatio_de_wiki_q "1603_25_1" "0" "0"

file_download_if_necessary "$DATA_1603_44_142" "1603_44_142" "csv" "tm.hxl.csv" "hxltmcli" "1"
file_convert_numerordinatio_de_hxltm "1603_44_142" "1" "0"
Expand Down
98 changes: 79 additions & 19 deletions officinam/999999999/999999999.lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -478,28 +478,10 @@ file_translate_csv_de_numerordinatio_q() {

# echo "${FUNCNAME[0]} sources changed_recently. Reloading..."

# if [ -z "$(stale_archive "$objectivum_archivum")" ]; then return 0; fi
if [ -z "$(stale_archive "$objectivum_archivum")" ]; then return 0; fi

echo "${FUNCNAME[0]} stale data on [$objectivum_archivum], refreshing..."

# echo "$fontem_archivum"

# echo "file_translate_csv_de_numerordinatio_q $1 TODO"
# echo "fontem_archivum [$fontem_archivum]"
# echo "objectivum_archivum [$objectivum_archivum]"
# echo "objectivum_archivum_temporarium [$objectivum_archivum_temporarium]"
# head -n 2 "$fontem_archivum"
# hxlcut \
# --include="#item+rem+i_qcc+is_zxxx+ix_wikiq,#item+conceptum+numerordinatio" \
# "$fontem_archivum" |
# hxlselect --query="#item+rem+i_qcc+is_zxxx+ix_wikiq>0" \
# >"$objectivum_archivum_temporarium"

# hxlcut \
# --include="#item+rem+i_qcc+is_zxxx+ix_wikiq" \
# "$fontem_archivum" |
# hxlselect --query="#item+rem+i_qcc+is_zxxx+ix_wikiq>0" \
# >"$objectivum_archivum_temporarium_b"
hxlcut \
--include='#*+ix_wikiq,#*+v_wiki_q,#item+conceptum+numerordinatio' \
"$fontem_archivum" |
Expand Down Expand Up @@ -538,6 +520,84 @@ file_translate_csv_de_numerordinatio_q() {
return 0
}

#######################################
# Merge no1.tm.hxl.csv with wikiq.tm.hxl.csv
#
# Globals:
# ROOTDIR
# Arguments:
# numerordinatio
# est_temporarium_fontem (default "1", from 99999/)
# est_temporarium_objectivumm (dfault "0", from real namespace)
# Outputs:
# Convert files
#######################################
file_merge_numerordinatio_de_wiki_q() {
numerordinatio="$1"
est_temporarium_fontem="${2:-"1"}"
est_temporarium_objectivum="${3:-"0"}"

_path=$(numerordinatio_neo_separatum "$numerordinatio" "/")
_nomen=$(numerordinatio_neo_separatum "$numerordinatio" "_")
_prefix=$(numerordinatio_neo_separatum "$numerordinatio" ":")

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="${ROOTDIR}/999999"
else
_basim_objectivum="${ROOTDIR}"
fi

fontem_archivum="${_basim_fontem}/$_path/$_nomen.no1.tm.hxl.csv"
fontem_q_archivum="${_basim_fontem}/$_path/$_nomen.wikiq.tm.hxl.csv"
objectivum_archivum="${_basim_objectivum}/$_path/$_nomen.no11.tm.hxl.csv"
objectivum_archivum_temporarium="${ROOTDIR}/999999/0/$_nomen.no11.tm.hxl.csv"
fontem_q_archivum_temporarium="${ROOTDIR}/999999/0/$_nomen.wikiq.tm.hxl.csv"
# objectivum_archivum_temporarium_b="${ROOTDIR}/999999/0/$_nomen.q.txt"
# objectivum_archivum_temporarium_b_u="${ROOTDIR}/999999/0/$_nomen.uniq.q.txt"
# objectivum_archivum_temporarium_b_u_wiki="${ROOTDIR}/999999/0/$_nomen.wikiq.tm.hxl.csv"

# TODO: implement check if necessary to revalidate
echo "${FUNCNAME[0]} sources changed_recently. Reloading..."

# echo "fontem_archivum $fontem_archivum"
# echo "fontem_q_archivum $fontem_q_archivum"
# echo "objectivum_archivum $objectivum_archivum"
# echo "hxlmerge --keys='#item+rem+i_qcc+is_zxxx+ix_wikiq' --tags='#item+rem' --merge='$fontem_archivum' $fontem_q_archivum > $objectivum_archivum_temporarium"
# echo ""
# echo ""
# echo ""
# echo "hxlmerge --keys='#item+rem+i_qcc+is_zxxx+ix_wikiq' --tags='#item+rem' --merge='$fontem_q_archivum' $fontem_archivum > $objectivum_archivum_temporarium"
hxlrename \
--rename='item+conceptum+codicem:#item+rem+i_qcc+is_zxxx+ix_wikiq' \
"$fontem_q_archivum" |
hxlselect --query='#*+ix_wikiq>0' --query='#*+v_wiki_q>0' \
>"$fontem_q_archivum_temporarium"


# hxlmerge --keys='#item+rem+i_qcc+is_zxxx+ix_wikiq' \
# --tags='#item+rem' \
# --merge="$fontem_q_archivum" \
# "$fontem_archivum" \
# >"$objectivum_archivum_temporarium"

hxlmerge --keys='#item+rem+i_qcc+is_zxxx+ix_wikiq' \
--tags='#item+rem' \
--merge="$fontem_q_archivum_temporarium" \
"$fontem_archivum" \
>"$objectivum_archivum_temporarium"

sed -i '1d' "${objectivum_archivum_temporarium}"

file_update_if_necessary csv "$objectivum_archivum_temporarium" "$objectivum_archivum"

return 0
}

#######################################
# contains(string, substring)
#
Expand Down

0 comments on commit 9e43101

Please sign in to comment.