Skip to content

Commit

Permalink
refactor excluded data types
Browse files Browse the repository at this point in the history
  • Loading branch information
eloiferrer committed Jul 22, 2024
1 parent 1e34b4d commit d366d50
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions mardi_importer/mardi_importer/integrator/MardiIntegrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ def __init__(self, languages=["en", "de"]) -> None:
'P2559', 'P2875', 'P3254', 'P3709', \
'P3713', 'P3734', 'P6104', 'P6685', \
'P8093', 'P8979', 'P12861']

self.excluded_datatypes = ['wikibase-lexeme', 'wikibase-sense', \
'wikibase-form', 'entity-schema']

def config(self):
"""
Expand Down Expand Up @@ -256,7 +259,7 @@ def import_entities(self, id_list=None, filename="", recurse=True):
continue

if entity.type == "property" and entity.datatype.value in \
["wikibase-lexeme", "wikibase-sense", "wikibase-form"]:
self.excluded_datatypes:
print(f"Warning: Lexemes not supported. Property skipped")
continue

Expand Down Expand Up @@ -389,8 +392,7 @@ def import_claim_entities(self, wikidata_id):
return None

if entity.type == "property" and \
entity.datatype.value in ["wikibase-lexeme", \
"wikibase-sense", "wikibase-form"]:
entity.datatype.value in self.excluded_datatypes:
return None

elif wikidata_id != entity.id:
Expand Down Expand Up @@ -534,7 +536,7 @@ def convert_claim_ids(self, entity):
new_c.id = None
else:
continue
elif c_dict["mainsnak"]["datatype"] in ["wikibase-lexeme", "wikibase-sense", "wikibase-form"]:
elif c_dict["mainsnak"]["datatype"] in self.excluded_datatypes:
continue
else:
self.convert_entity_links(snak=c_dict["mainsnak"])
Expand Down Expand Up @@ -592,7 +594,7 @@ def get_references(self, claim):
continue
snak["datavalue"]["value"]["id"] = new_snak_id
snak["datavalue"]["value"]["numeric-id"] = int(new_snak_id[1:])
elif snak["datatype"] in ["wikibase-lexeme", "wikibase-sense", "wikibase-form"]:
elif snak["datatype"] in self.excluded_datatypes:
continue
else:
self.convert_entity_links(
Expand Down Expand Up @@ -643,7 +645,7 @@ def get_qualifiers(self, claim):
qual_val["datavalue"]["value"]["numeric-id"] = int(
new_qual_val_id[1:]
)
elif qual_val["datatype"] in ["wikibase-lexeme", "wikibase-sense", "wikibase-form"]:
elif qual_val["datatype"] in self.excluded_datatypes:
continue
else:
self.convert_entity_links(
Expand Down

0 comments on commit d366d50

Please sign in to comment.