Search in sources :

Example 1 with ReconPropertyIdValue

use of org.openrefine.wikidata.schema.entityvalues.ReconPropertyIdValue in project OpenRefine by OpenRefine.

the class WbEntityVariableTest method testReconciledPropertyCell.

@Test
public void testReconciledPropertyCell() {
    Recon recon = Recon.makeWikidataRecon(3782378L);
    recon.judgment = Recon.Judgment.Matched;
    recon.match = new ReconCandidate("P123", "some item", null, 100.0);
    Cell cell = new Cell("some value", recon);
    evaluatesTo(new ReconPropertyIdValue(recon, "some value"), cell);
}
Also used : Recon(com.google.refine.model.Recon) Cell(com.google.refine.model.Cell) ReconPropertyIdValue(org.openrefine.wikidata.schema.entityvalues.ReconPropertyIdValue) ReconCandidate(com.google.refine.model.ReconCandidate) JacksonSerializationTest(org.openrefine.wikidata.testing.JacksonSerializationTest) Test(org.testng.annotations.Test)

Example 2 with ReconPropertyIdValue

use of org.openrefine.wikidata.schema.entityvalues.ReconPropertyIdValue in project OpenRefine by OpenRefine.

the class WbEntityVariable method fromCell.

@Override
public EntityIdValue fromCell(Cell cell, ExpressionContext ctxt) throws SkipSchemaExpressionException {
    if (cell.recon != null && (Judgment.Matched.equals(cell.recon.judgment) || Judgment.New.equals(cell.recon.judgment))) {
        if (Judgment.New.equals(cell.recon.judgment)) {
            return new ReconItemIdValue(cell.recon, cell.value.toString());
        }
        EntityIdValue entityIdValue = EntityIdValueImpl.fromId(cell.recon.match.id, cell.recon.identifierSpace);
        EntityIdValue reconEntityIdValue = null;
        String entityType = null;
        if (entityIdValue instanceof ItemIdValue) {
            reconEntityIdValue = new ReconItemIdValue(cell.recon, cell.value.toString());
            entityType = "item";
        } else if (entityIdValue instanceof MediaInfoIdValue) {
            reconEntityIdValue = new ReconMediaInfoIdValue(cell.recon, cell.value.toString());
            entityType = "mediainfo";
        } else if (entityIdValue instanceof PropertyIdValue) {
            reconEntityIdValue = new ReconPropertyIdValue(cell.recon, cell.value.toString());
            entityType = "property";
        }
        if (reconEntityIdValue == null) {
            throw new SkipSchemaExpressionException();
        }
        if (cell.recon.identifierSpace == null || !cell.recon.identifierSpace.equals(ctxt.getBaseIRIForEntityType(entityType))) {
            QAWarning warning = new QAWarning("invalid-identifier-space", null, QAWarning.Severity.INFO, 1);
            warning.setProperty("example_cell", cell.value.toString());
            warning.setProperty("expected_site_iri", ctxt.getBaseIRIForEntityType(entityType));
            ctxt.addWarning(warning);
            throw new SkipSchemaExpressionException();
        }
        return reconEntityIdValue;
    }
    throw new SkipSchemaExpressionException();
}
Also used : ReconItemIdValue(org.openrefine.wikidata.schema.entityvalues.ReconItemIdValue) ItemIdValue(org.wikidata.wdtk.datamodel.interfaces.ItemIdValue) PropertyIdValue(org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue) ReconPropertyIdValue(org.openrefine.wikidata.schema.entityvalues.ReconPropertyIdValue) ReconItemIdValue(org.openrefine.wikidata.schema.entityvalues.ReconItemIdValue) ReconMediaInfoIdValue(org.openrefine.wikidata.schema.entityvalues.ReconMediaInfoIdValue) MediaInfoIdValue(org.wikidata.wdtk.datamodel.interfaces.MediaInfoIdValue) SkipSchemaExpressionException(org.openrefine.wikidata.schema.exceptions.SkipSchemaExpressionException) EntityIdValue(org.wikidata.wdtk.datamodel.interfaces.EntityIdValue) ReconPropertyIdValue(org.openrefine.wikidata.schema.entityvalues.ReconPropertyIdValue) QAWarning(org.openrefine.wikidata.qa.QAWarning) ReconMediaInfoIdValue(org.openrefine.wikidata.schema.entityvalues.ReconMediaInfoIdValue)

Aggregations

ReconPropertyIdValue (org.openrefine.wikidata.schema.entityvalues.ReconPropertyIdValue)2 Cell (com.google.refine.model.Cell)1 Recon (com.google.refine.model.Recon)1 ReconCandidate (com.google.refine.model.ReconCandidate)1 QAWarning (org.openrefine.wikidata.qa.QAWarning)1 ReconItemIdValue (org.openrefine.wikidata.schema.entityvalues.ReconItemIdValue)1 ReconMediaInfoIdValue (org.openrefine.wikidata.schema.entityvalues.ReconMediaInfoIdValue)1 SkipSchemaExpressionException (org.openrefine.wikidata.schema.exceptions.SkipSchemaExpressionException)1 JacksonSerializationTest (org.openrefine.wikidata.testing.JacksonSerializationTest)1 Test (org.testng.annotations.Test)1 EntityIdValue (org.wikidata.wdtk.datamodel.interfaces.EntityIdValue)1 ItemIdValue (org.wikidata.wdtk.datamodel.interfaces.ItemIdValue)1 MediaInfoIdValue (org.wikidata.wdtk.datamodel.interfaces.MediaInfoIdValue)1 PropertyIdValue (org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue)1