From e920c0f421d2876a3fa4f67714e700c15d705fda Mon Sep 17 00:00:00 2001 From: Antonin Delpeuch Date: Wed, 10 Jan 2018 15:26:11 +0000 Subject: [PATCH] Add info issues for empty edits and no warnings --- .../wikidata/module/langs/translation-en.json | 8 ++++++++ .../openrefine/wikidata/qa/EditInspector.java | 7 +++++++ .../openrefine/wikidata/qa/QAWarningStore.java | 10 ++++++++++ .../scrutinizers/NoEditsMadeScrutinizer.java | 18 ++++++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/NoEditsMadeScrutinizer.java diff --git a/extensions/wikidata/module/langs/translation-en.json b/extensions/wikidata/module/langs/translation-en.json index d8882f207..c1244e248 100644 --- a/extensions/wikidata/module/langs/translation-en.json +++ b/extensions/wikidata/module/langs/translation-en.json @@ -92,6 +92,14 @@ "single-valued-property-added-more-than-once": { "title": "Single valued property added more than once.", "body": "A property that is expected to be used at most once on each item has been added multiple times on the same item." + }, + "no-edit-generated": { + "title": "No edit was generated.", + "body": "There might be something wrong with your schema." + }, + "no-issue-detected": { + "title": "No issue was detected in your edits.", + "body": "Note that OpenRefine cannot detect all the types of problems Wikidata edits can have." } } } diff --git a/extensions/wikidata/src/org/openrefine/wikidata/qa/EditInspector.java b/extensions/wikidata/src/org/openrefine/wikidata/qa/EditInspector.java index bc2ab001f..7bf5b1ad3 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/qa/EditInspector.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/qa/EditInspector.java @@ -8,6 +8,7 @@ import org.openrefine.wikidata.qa.scrutinizers.EditScrutinizer; import org.openrefine.wikidata.qa.scrutinizers.FormatConstraintScrutinizer; import org.openrefine.wikidata.qa.scrutinizers.InverseConstraintScrutinizer; import org.openrefine.wikidata.qa.scrutinizers.NewItemScrutinizer; +import org.openrefine.wikidata.qa.scrutinizers.NoEditsMadeScrutinizer; import org.openrefine.wikidata.qa.scrutinizers.QualifierCompatibilityScrutinizer; import org.openrefine.wikidata.qa.scrutinizers.RestrictedPositionScrutinizer; import org.openrefine.wikidata.qa.scrutinizers.SelfReferentialScrutinizer; @@ -37,6 +38,7 @@ public class EditInspector { register(new RestrictedPositionScrutinizer()); register(new QualifierCompatibilityScrutinizer()); register(new SingleValueScrutinizer()); + register(new NoEditsMadeScrutinizer()); } /** @@ -58,6 +60,11 @@ public class EditInspector { for(EditScrutinizer scrutinizer : scrutinizers.values()) { scrutinizer.scrutinize(editBatch); } + + if (warningStore.getNbWarnings() == 0) { + warningStore.addWarning(new QAWarning( + "no-issue-detected", null, QAWarning.Severity.INFO, 0)); + } } /** diff --git a/extensions/wikidata/src/org/openrefine/wikidata/qa/QAWarningStore.java b/extensions/wikidata/src/org/openrefine/wikidata/qa/QAWarningStore.java index 5824fe2d7..508fe5c39 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/qa/QAWarningStore.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/qa/QAWarningStore.java @@ -16,6 +16,7 @@ public class QAWarningStore { private Map map; private QAWarning.Severity maxSeverity; + private int totalWarnings; public QAWarningStore() { this.map = new HashMap<>(); @@ -32,6 +33,7 @@ public class QAWarningStore { if (severity.compareTo(maxSeverity) > 0) { maxSeverity = severity; } + totalWarnings += warning.getCount(); if (map.containsKey(aggregationKey)) { QAWarning existing = map.get(aggregationKey); existing.aggregate(warning); @@ -57,4 +59,12 @@ public class QAWarningStore { QAWarning.Severity getMaxSeverity() { return maxSeverity; } + + /** + * Returns the total number of warnings + */ + @JsonProperty("nb_warnings") + int getNbWarnings() { + return totalWarnings; + } } diff --git a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/NoEditsMadeScrutinizer.java b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/NoEditsMadeScrutinizer.java new file mode 100644 index 000000000..35ffc3666 --- /dev/null +++ b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/NoEditsMadeScrutinizer.java @@ -0,0 +1,18 @@ +package org.openrefine.wikidata.qa.scrutinizers; + +import java.util.List; + +import org.openrefine.wikidata.schema.ItemUpdate; + + +public class NoEditsMadeScrutinizer extends EditScrutinizer { + + @Override + public void scrutinize(List edit) { + if(edit.stream().allMatch(e -> e.isNull())) { + info("no-edit-generated"); + } + + } + +}