Fix unit checking with novalue claims

This commit is contained in:
Antonin Delpeuch 2018-06-09 13:54:16 +01:00
parent 4bb3505aa5
commit ddbe4fe2a2
2 changed files with 4 additions and 6 deletions

View File

@ -213,11 +213,7 @@ public class WikidataConstraintFetcher implements ConstraintFetcher {
if (specs != null) {
List<Value> properties = findValues(specs, ALLOWED_UNITS_CONSTRAINT_PID);
if (properties.contains(null)) {
return Collections.emptySet();
} else {
return properties.stream().map(e -> (ItemIdValue) e).collect(Collectors.toSet());
}
return properties.stream().map(e -> e == null ? null : (ItemIdValue) e).collect(Collectors.toSet());
}
return null;
}

View File

@ -58,7 +58,9 @@ public class QuantityScrutinizer extends SnakScrutinizer {
issue.setProperty("example_value", value.getNumericValue().toString());
issue.setProperty("example_item_entity", entityId);
if (currentUnit != null) {
issue.setProperty("unit_entity", currentUnit);
issue.setProperty("unit_entity",
// this is a hack but it will not be needed anymore in the upcoming version of Wikidata-Toolkit
Datamodel.makeWikidataItemIdValue(currentUnit.substring(currentUnit.indexOf("Q"))));
}
addIssue(issue);
}