I am using the wikidata toolkit and I want to get a list of all events.
I wrote a EntityDocumentProcessor, where I want to filter for the events out of my dump. Well I know that the event document has the id Q1190554
and that I have to somehow check if the instance of the current itemDocument is an "instance of" (P31) of an event.
@Override
public void processItemDocument(ItemDocument itemDocument) {
boolean isEvent = false;
for (StatementGroup statementGroup : itemDocument.getStatementGroups()) {
switch (statementGroup.getProperty().getId()) {
case "P31": // P31 is "instance of"
isEvent = containsValue(statementGroup, filterClass);
break;
case "P279": // P279 is "subclass of"
if (!isEvent) {
isEvent = containsValue(statementGroup, filterClass);
}
break;
}
}
}
private boolean containsValue(StatementGroup statementGroup, Value value) {
for (Statement s : statementGroup.getStatements()) {
if (value.equals(s.getValue())) {
return true;
}
}
return false;
}
This approach worked pretty good for getting people. But the problem with events is that events like WW2 (https://www.wikidata.org/wiki/Q362) dont have the event directly mapped. The event is somewhere hidden. Does anyone knows a way how I can easily check if the current itemDocument is an event?