use of org.openrefine.wikidata.qa.QAWarning in project OpenRefine by OpenRefine.
the class EnglishDescriptionScrutinizer method checkUppercase.
// Descriptions begin with a lowercase letter except when uppercase would normally be required or expected.
protected void checkUppercase(TermedStatementEntityEdit update, String descText) {
assert descText.length() > 0;
char first = descText.charAt(0);
if ('A' <= first && first <= 'Z') {
QAWarning issue = new QAWarning(descBeginWithUppercase, null, QAWarning.Severity.INFO, 1);
issue.setProperty("example_entity", update.getEntityId());
issue.setProperty("description", descText);
issue.setProperty("lang", LANG);
issue.setProperty("uppercase_letter", first);
addIssue(issue);
}
}
use of org.openrefine.wikidata.qa.QAWarning in project OpenRefine by OpenRefine.
the class ItemRequiresScrutinizer method scrutinize.
@Override
public void scrutinize(TermedStatementEntityEdit update) {
Map<PropertyIdValue, Set<Value>> propertyIdValueValueMap = new HashMap<>();
for (Statement statement : update.getAddedStatements()) {
Snak mainSnak = statement.getClaim().getMainSnak();
PropertyIdValue pid = mainSnak.getPropertyId();
Set<Value> values;
if (mainSnak instanceof ValueSnak) {
Value value = ((ValueSnak) mainSnak).getValue();
if (propertyIdValueValueMap.containsKey(pid)) {
values = propertyIdValueValueMap.get(pid);
} else {
values = new HashSet<>();
}
values.add(value);
propertyIdValueValueMap.put(pid, values);
}
}
for (PropertyIdValue propertyId : propertyIdValueValueMap.keySet()) {
List<Statement> constraintDefinitions = _fetcher.getConstraintsByType(propertyId, itemRequiresConstraintQid);
for (Statement statement : constraintDefinitions) {
ItemRequiresConstraint constraint = new ItemRequiresConstraint(statement);
PropertyIdValue itemRequiresPid = constraint.itemRequiresPid;
List<Value> itemList = constraint.itemList;
if (!propertyIdValueValueMap.containsKey(itemRequiresPid)) {
QAWarning issue = new QAWarning(update.isNew() ? newItemRequirePropertyType : existingItemRequirePropertyType, propertyId.getId() + itemRequiresPid.getId(), update.isNew() ? QAWarning.Severity.WARNING : QAWarning.Severity.INFO, 1);
issue.setProperty("property_entity", propertyId);
issue.setProperty("added_property_entity", itemRequiresPid);
issue.setProperty("example_entity", update.getEntityId());
addIssue(issue);
} else if (raiseWarning(propertyIdValueValueMap, itemRequiresPid, itemList)) {
QAWarning issue = new QAWarning(update.isNew() ? newItemRequireValuesType : existingItemRequireValuesType, propertyId.getId() + itemRequiresPid.getId(), update.isNew() ? QAWarning.Severity.WARNING : QAWarning.Severity.INFO, 1);
issue.setProperty("property_entity", propertyId);
issue.setProperty("added_property_entity", itemRequiresPid);
issue.setProperty("example_entity", update.getEntityId());
addIssue(issue);
}
}
}
}
use of org.openrefine.wikidata.qa.QAWarning in project OpenRefine by OpenRefine.
the class WbLanguageVariable method fromCell.
@Override
public String fromCell(Cell cell, ExpressionContext ctxt) throws SkipSchemaExpressionException {
if (cell.value != null && !cell.value.toString().isEmpty()) {
String code = cell.value.toString().trim();
String mediaWikiApiEndpoint = ctxt.getMediaWikiApiEndpoint();
String normalized = WbLanguageConstant.normalizeLanguageCode(code, mediaWikiApiEndpoint);
if (normalized != null) {
return normalized;
} else {
QAWarning issue = new QAWarning("ignored-language", null, QAWarning.Severity.WARNING, 1);
issue.setProperty("example_value", cell.value.toString());
ctxt.addWarning(issue);
}
}
throw new SkipSchemaExpressionException();
}
use of org.openrefine.wikidata.qa.QAWarning in project OpenRefine by OpenRefine.
the class SelfReferentialScrutinizer method scrutinize.
@Override
public void scrutinize(Snak snak, EntityIdValue entityId, boolean added) {
if (!added) {
return;
}
if (snak instanceof ValueSnak && entityId.equals(((ValueSnak) snak).getValue())) {
QAWarning issue = new QAWarning(type, null, QAWarning.Severity.WARNING, 1);
issue.setProperty("example_entity", entityId);
addIssue(issue);
}
}
Aggregations