Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated wikidata mapper, expanded guesser and activity mapping #205

Merged
merged 2 commits into from
Jan 25, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions pipeline/sources/general/wikidata/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,23 @@ def guess_type(self, data):
"Q1790144": model.MeasurementUnit,
"Q3647172": model.MeasurementUnit,
"Q3550873": model.MeasurementUnit,
"Q12418": model.HumanMadeObject,
"Q45585": model.HumanMadeObject,
"Q175036": model.HumanMadeObject,
"Q698487": model.HumanMadeObject,
"Q464782": model.HumanMadeObject,
"Q83872": model.HumanMadeObject,
"Q1044742": model.HumanMadeObject,
"Q1404472": model.Period,
"Q45805": model.Period,
"Q184963": model.Period,
"Q11761": model.Period,
"Q9903": model.Period,
"Q173034": model.Activity,
"Q901769": model.Activity,
"Q688909": model.Activity,
"Q193155": model.Activity,
"Q459447": model.Activity
}

if "P31" in data:
Expand Down Expand Up @@ -234,13 +251,14 @@ def guess_type(self, data):
"P1334",
"P1335",
],
# "event": ["P580", "P585", "P582", "P710", "P1132", "P1542"],
"activity": ["P580", "P582", "P710", "P1132", "P1542", "P664", "P585"],
"period": ["P580", "P582", "P155", "P156", "P276"],
"type": ["P1014", "P1843", "P1036"],
"language": ["P282", "P1098", "P3823", "P218", "P219", "P220", "P1394"],
"currency": ["P489", "P562", "P498"],
"unit": ["P2370", "P2442", "P111"],
"material": ["P2054", "P2067"],
"object": ["P127", "P186", "P217", "P2049", "P571", "P176"], # height used on people
"object": ["P127", "P88", "P186", "P217", "P608", "P2049", "P176"], # height used on people
"text": ["P747", "P50", "P655", "P123", "P291", "P840"],
}

Expand All @@ -255,6 +273,8 @@ def guess_type(self, data):
"material": model.Material,
"object": model.HumanMadeObject,
"text": model.LinguisticObject,
"activity": model.Activity,
"period": model.Period
}

hits = {}
Expand Down Expand Up @@ -1096,6 +1116,7 @@ def process_event(self, data, top):

def process_period(self, data, top):
self.process_imageref(data, top)
self.process_activity(data, top)

def process_activity(self, data, top):
startTime = data.get("P580")
Expand Down Expand Up @@ -1136,7 +1157,11 @@ def process_activity(self, data, top):
broader = data.get("P361",[])
if broader:
for b in broader:
top.part_of = model.Activity(ident=self.expand_uri(b))
pref = self.get_reference(b)
if pref and pref.__class__ == model.Period:
top.part_of = model.Period(ident=self.expand_uri(b))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this just be top.part_of = pref ? No need to test pref.class, just if it's not None.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. I think I was confused because both process_period and process_event just point to process_activity. Maybe I should split up the process_activity code to each more specific Class, e.g. Periods don't have participants. I'll write that up and re-submit.

elif pref and pref.__class__ == model.Activity:
top.part_of = model.Activity(ident=self.expand_uri(b))


country = data.get("P17",[])
Expand Down