From ddbe4fe2a2c5b003ad7d293c97358443122c17f2 Mon Sep 17 00:00:00 2001 From: Antonin Delpeuch Date: Sat, 9 Jun 2018 13:54:16 +0100 Subject: [PATCH] Fix unit checking with novalue claims --- .../openrefine/wikidata/qa/WikidataConstraintFetcher.java | 6 +----- .../wikidata/qa/scrutinizers/QuantityScrutinizer.java | 4 +++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/extensions/wikidata/src/org/openrefine/wikidata/qa/WikidataConstraintFetcher.java b/extensions/wikidata/src/org/openrefine/wikidata/qa/WikidataConstraintFetcher.java index 29f9337e4..20036b26f 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/qa/WikidataConstraintFetcher.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/qa/WikidataConstraintFetcher.java @@ -213,11 +213,7 @@ public class WikidataConstraintFetcher implements ConstraintFetcher { if (specs != null) { List 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; } diff --git a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/QuantityScrutinizer.java b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/QuantityScrutinizer.java index a32f3e2a2..d1f1dc9a9 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/QuantityScrutinizer.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/QuantityScrutinizer.java @@ -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); }