Add support for Wikidata single best value constraint
This commit is contained in:
parent
ddbe4fe2a2
commit
e2ae09f5be
@ -105,6 +105,11 @@ public interface ConstraintFetcher {
|
|||||||
*/
|
*/
|
||||||
boolean hasSingleValue(PropertyIdValue pid);
|
boolean hasSingleValue(PropertyIdValue pid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is this property expected to have a single best value only?
|
||||||
|
*/
|
||||||
|
boolean hasSingleBestValue(PropertyIdValue pid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is this property expected to have distinct values?
|
* Is this property expected to have distinct values?
|
||||||
*/
|
*/
|
||||||
|
@ -79,6 +79,7 @@ public class WikidataConstraintFetcher implements ConstraintFetcher {
|
|||||||
public static String DISALLOWED_VALUES_CONSTRAINT_PID = "P2305";
|
public static String DISALLOWED_VALUES_CONSTRAINT_PID = "P2305";
|
||||||
|
|
||||||
public static String SINGLE_VALUE_CONSTRAINT_QID = "Q19474404";
|
public static String SINGLE_VALUE_CONSTRAINT_QID = "Q19474404";
|
||||||
|
public static String SINGLE_BEST_VALUE_CONSTRAINT_QID = "Q52060874";
|
||||||
public static String DISTINCT_VALUES_CONSTRAINT_QID = "Q21502410";
|
public static String DISTINCT_VALUES_CONSTRAINT_QID = "Q21502410";
|
||||||
|
|
||||||
public static String NO_BOUNDS_CONSTRAINT_QID = "Q51723761";
|
public static String NO_BOUNDS_CONSTRAINT_QID = "Q51723761";
|
||||||
@ -165,6 +166,11 @@ public class WikidataConstraintFetcher implements ConstraintFetcher {
|
|||||||
return getSingleConstraint(pid, SINGLE_VALUE_CONSTRAINT_QID) != null;
|
return getSingleConstraint(pid, SINGLE_VALUE_CONSTRAINT_QID) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasSingleBestValue(PropertyIdValue pid) {
|
||||||
|
return getSingleConstraint(pid, SINGLE_BEST_VALUE_CONSTRAINT_QID) != null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasDistinctValues(PropertyIdValue pid) {
|
public boolean hasDistinctValues(PropertyIdValue pid) {
|
||||||
return getSingleConstraint(pid, DISTINCT_VALUES_CONSTRAINT_QID) != null;
|
return getSingleConstraint(pid, DISTINCT_VALUES_CONSTRAINT_QID) != null;
|
||||||
|
@ -35,6 +35,9 @@ import org.wikidata.wdtk.datamodel.interfaces.Statement;
|
|||||||
* For now this scrutinizer only checks for uniqueness at the item level (it
|
* For now this scrutinizer only checks for uniqueness at the item level (it
|
||||||
* ignores qualifiers and references).
|
* ignores qualifiers and references).
|
||||||
*
|
*
|
||||||
|
* Given that all ranks are currently set to Normal, this also checks for
|
||||||
|
* single best values.
|
||||||
|
*
|
||||||
* @author Antonin Delpeuch
|
* @author Antonin Delpeuch
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -54,7 +57,7 @@ public class SingleValueScrutinizer extends EditScrutinizer {
|
|||||||
issue.setProperty("property_entity", pid);
|
issue.setProperty("property_entity", pid);
|
||||||
issue.setProperty("example_entity", update.getItemId());
|
issue.setProperty("example_entity", update.getItemId());
|
||||||
addIssue(issue);
|
addIssue(issue);
|
||||||
} else if (_fetcher.hasSingleValue(pid)) {
|
} else if (_fetcher.hasSingleValue(pid) || _fetcher.hasSingleBestValue(pid)) {
|
||||||
seenSingleProperties.add(pid);
|
seenSingleProperties.add(pid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,6 +104,11 @@ public class MockConstraintFetcher implements ConstraintFetcher {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasSingleBestValue(PropertyIdValue pid) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasDistinctValues(PropertyIdValue pid) {
|
public boolean hasDistinctValues(PropertyIdValue pid) {
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user