Skip to content

Commit

Permalink
rdf+bcp47+hxl (#41), admin-l (#39), pcodes (#2): not perfect but hard…
Browse files Browse the repository at this point in the history
…coded list will make it work for common cases at sort term
  • Loading branch information
fititnt committed Jun 12, 2022
1 parent a4a3508 commit 21a9f6a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
47 changes: 47 additions & 0 deletions officina/999999999/0/L999999999_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,36 @@

# @TODO this part is somewhat hardcoded
HXL_HASH_ET_ATTRIBUTA_AD_RDF = {
# @TODO
# - #country+code+v_iso3166p1a2
'#country+code+v_numerodinatio': {
'__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'
},
'#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'
},
'#adm2+code+v_numerodinatio': {
'__no1bpc47__': 'qcc-Zxxx-r-aOBO-abfo29-anop-sU2200-s5002-snop-pOBO-pbfo124-ps5002-pOBO-pbfo171-ps5001',
'__no1hxl__': '#item+rem+i_qcc+is_zxxx+rdf_a_obo_bfo29+rdf_p_obo_bfo124_s5002+rdf_p_obo_bfo171_s5001+rdf_s_u2200_s5002'
},
'#adm3+code+v_numerodinatio': {
'__no1bpc47__': 'qcc-Zxxx-r-aOBO-abfo29-anop-sU2200-s5003-snop-pOBO-pbfo124-ps5003-pOBO-pbfo171-ps5002',
'__no1hxl__': '#item+rem+i_qcc+is_zxxx+rdf_a_obo_bfo29+rdf_p_obo_bfo124_s5003+rdf_p_obo_bfo171_s5002+rdf_s_u2200_s5003'
},
'#adm4+code+v_numerodinatio': {
'__no1bpc47__': 'qcc-Zxxx-r-aOBO-abfo29-anop-sU2200-s5004-snop-pOBO-pbfo124-ps5004-pOBO-pbfo171-ps5003',
'__no1hxl__': '#item+rem+i_qcc+is_zxxx+rdf_a_obo_bfo29+rdf_p_obo_bfo124_s5004+rdf_p_obo_bfo171_s5003+rdf_s_u2200_s5004'
},
'#adm5+code+v_numerodinatio': {
'__no1bpc47__': 'qcc-Zxxx-r-aOBO-abfo29-anop-sU2200-s5005-snop-pOBO-pbfo124-ps5005-pOBO-pbfo171-ps5004',
'__no1hxl__': '#item+rem+i_qcc+is_zxxx+rdf_a_obo_bfo29+rdf_p_obo_bfo124_s5005+rdf_p_obo_bfo171_s5004+rdf_s_u2200_s5005'
},
'#adm6+code+v_numerodinatio': {
'__no1bpc47__': 'qcc-Zxxx-r-aOBO-abfo29-anop-sU2200-s5006-snop-pOBO-pbfo124-ps5005-pOBO-pbfo171-ps5004',
'__no1hxl__': '#item+rem+i_qcc+is_zxxx+rdf_a_obo_bfo29+rdf_p_obo_bfo124_s5005+rdf_p_obo_bfo171_s5004+rdf_s_u2200_s5005'
},
# @see https://www.wikidata.org/wiki/EntitySchema:E49
# publication date (P577)
# date or point in time when a work was first published or released
Expand Down Expand Up @@ -3029,6 +3059,10 @@ def quod_no1_de_hxltm_rei(self, hxlhashtag: str) -> str:
not hxlhashtag.startswith('#'):
return ''

_hxl = HXLHashtagSimplici(hxlhashtag).praeparatio()

return _hxl.quod_numerordinatio()

# print('hxlhashtag', hxlhashtag)
# Time-related hashtags
# @see https://www.wikidata.org/wiki/Wikidata:List_of_properties/time
Expand Down Expand Up @@ -3873,6 +3907,10 @@ def quod_numerordinatio(self, caput_contextui: List[str] = None):
if self.hashtag in BCP47_EX_HXL:
# Already '#item+conceptum+codicem'/'#item+conceptum+numerordinatio'
return self.hashtag

if self.hashtag in HXL_HASH_ET_ATTRIBUTA_AD_RDF:
return HXL_HASH_ET_ATTRIBUTA_AD_RDF[self.hashtag]['__no1hxl__']

resultatum = []
rdf_parts = []
# if self.ad_rdf is None:
Expand Down Expand Up @@ -3936,6 +3974,10 @@ def quod_numerordinatio(self, caput_contextui: List[str] = None):
_linguae[0], _script[0], _rdf_parts
)
else:
if len(_rdf_parts) == 0:
return '#meta+ERROR+{0}'.format(
self.hashtag.replace('#', '')
)
return '#item+rem+i_qcc+is_zxxx{0}'.format(
_rdf_parts
)
Expand Down Expand Up @@ -4054,6 +4096,11 @@ def hxl_hashtag_to_bcp47(
# raise ValueError(hashtag, _hashtag)
hashtag = _hashtag

if hashtag in HXL_HASH_ET_ATTRIBUTA_AD_RDF:
_hashtag = _know_hardcoded[hashtag]['hxl']
result['_callbacks']['hxl_original'] = hashtag
hashtag = HXL_HASH_ET_ATTRIBUTA_AD_RDF[hashtag]['__no1hxl__']

parts = hashtag.split('+')
# bash_hashtag = parts.pop(0)
# print('parts', parts)
Expand Down
4 changes: 2 additions & 2 deletions officina/999999999/1603_45_16.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1026,10 +1026,10 @@ __temp_download_external_cod_data() {
# __temp_download_external_cod_data
# exit 1
# echo "all"
bootstrap_1603_45_16__all
# bootstrap_1603_45_16__all
# bootstrap_1603_45_16__item "1603_45_16" "24" "AGO" "AO" "1" "1" "0"
# bootstrap_1603_45_16__item "1603_45_16" "24" "AGO" "AO" "3" "1" "0"
# __temp_preproces_quicktest_1603_16_24
__temp_preproces_quicktest_1603_16_24
exit 0

# bootstrap_1603_45_16__all
Expand Down

0 comments on commit 21a9f6a

Please sign in to comment.