Report duplicate items in DistinctValuesScrutinizer
This commit is contained in:
parent
212b1b3dd3
commit
699ec16082
@ -95,7 +95,7 @@
|
|||||||
},
|
},
|
||||||
"identical-values-for-distinct-valued-property": {
|
"identical-values-for-distinct-valued-property": {
|
||||||
"title": "Identical values for {property_entity}",
|
"title": "Identical values for {property_entity}",
|
||||||
"body": "This property should have distinct values."
|
"body": "This property should have distinct values, but the same value was found on {item1_entity} and {item2_entity} for instance."
|
||||||
},
|
},
|
||||||
"no-edit-generated": {
|
"no-edit-generated": {
|
||||||
"title": "No edit was generated.",
|
"title": "No edit was generated.",
|
||||||
|
@ -20,7 +20,7 @@ import org.wikidata.wdtk.datamodel.interfaces.Value;
|
|||||||
*/
|
*/
|
||||||
public class DistinctValuesScrutinizer extends StatementScrutinizer {
|
public class DistinctValuesScrutinizer extends StatementScrutinizer {
|
||||||
|
|
||||||
private Map<PropertyIdValue, Set<Value>> _seenValues;
|
private Map<PropertyIdValue, Map<Value, EntityIdValue>> _seenValues;
|
||||||
|
|
||||||
public DistinctValuesScrutinizer() {
|
public DistinctValuesScrutinizer() {
|
||||||
_seenValues = new HashMap<>();
|
_seenValues = new HashMap<>();
|
||||||
@ -31,22 +31,24 @@ public class DistinctValuesScrutinizer extends StatementScrutinizer {
|
|||||||
PropertyIdValue pid = statement.getClaim().getMainSnak().getPropertyId();
|
PropertyIdValue pid = statement.getClaim().getMainSnak().getPropertyId();
|
||||||
if (_fetcher.hasDistinctValues(pid)) {
|
if (_fetcher.hasDistinctValues(pid)) {
|
||||||
Value mainSnakValue = statement.getClaim().getMainSnak().getValue();
|
Value mainSnakValue = statement.getClaim().getMainSnak().getValue();
|
||||||
Set<Value> seen = _seenValues.get(pid);
|
Map<Value, EntityIdValue> seen = _seenValues.get(pid);
|
||||||
if (seen == null) {
|
if (seen == null) {
|
||||||
seen = new HashSet<Value>();
|
seen = new HashMap<Value, EntityIdValue>();
|
||||||
_seenValues.put(pid, seen);
|
_seenValues.put(pid, seen);
|
||||||
}
|
}
|
||||||
if (seen.contains(mainSnakValue)) {
|
if (seen.containsKey(mainSnakValue)) {
|
||||||
|
EntityIdValue otherId = seen.get(mainSnakValue);
|
||||||
QAWarning issue = new QAWarning(
|
QAWarning issue = new QAWarning(
|
||||||
"identical-values-for-distinct-valued-property",
|
"identical-values-for-distinct-valued-property",
|
||||||
pid.getId(),
|
pid.getId(),
|
||||||
QAWarning.Severity.IMPORTANT,
|
QAWarning.Severity.IMPORTANT,
|
||||||
1);
|
1);
|
||||||
issue.setProperty("property_entity", pid);
|
issue.setProperty("property_entity", pid);
|
||||||
// TODO also report the items on which the property is duplicated
|
issue.setProperty("item1_entity", entityId);
|
||||||
|
issue.setProperty("item2_entity", otherId);
|
||||||
addIssue(issue);
|
addIssue(issue);
|
||||||
} else {
|
} else {
|
||||||
seen.add(mainSnakValue);
|
seen.put(mainSnakValue, entityId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user