use of org.wikidata.wdtk.datamodel.interfaces.StatementRank in project OpenRefine by OpenRefine.
the class WbStatementExpr method evaluate.
public StatementEdit evaluate(ExpressionContext ctxt, EntityIdValue subject, PropertyIdValue propertyId) throws SkipSchemaExpressionException {
Snak mainSnak = null;
if (mainSnakValueExpr != null) {
Value mainSnakValue = mainSnakValueExpr.evaluate(ctxt);
mainSnak = Datamodel.makeValueSnak(propertyId, mainSnakValue);
} else {
// hack to make sure we have a non-null snak
mainSnak = Datamodel.makeNoValueSnak(propertyId);
}
// evaluate qualifiers
List<Snak> qualifiers = new ArrayList<Snak>(getQualifiers().size());
for (WbSnakExpr qExpr : getQualifiers()) {
try {
qualifiers.add(qExpr.evaluate(ctxt));
} catch (SkipSchemaExpressionException e) {
QAWarning warning = new QAWarning("ignored-qualifiers", null, QAWarning.Severity.INFO, 1);
warning.setProperty("example_entity", subject);
warning.setProperty("example_property_entity", mainSnak.getPropertyId());
ctxt.addWarning(warning);
}
}
List<SnakGroup> groupedQualifiers = groupSnaks(qualifiers);
Claim claim = Datamodel.makeClaim(subject, mainSnak, groupedQualifiers);
// evaluate references
List<Reference> references = new ArrayList<Reference>();
for (WbReferenceExpr rExpr : getReferences()) {
try {
references.add(rExpr.evaluate(ctxt));
} catch (SkipSchemaExpressionException e) {
QAWarning warning = new QAWarning("ignored-references", null, QAWarning.Severity.INFO, 1);
warning.setProperty("example_entity", subject);
warning.setProperty("example_property_entity", mainSnak.getPropertyId());
ctxt.addWarning(warning);
}
}
StatementRank rank = StatementRank.NORMAL;
return new StatementEdit(Datamodel.makeStatement(claim, references, rank, ""), merger, mode);
}
Aggregations