Search in sources :

Example 1 with ReconItemIdValue

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

the class WbItemVariable method fromCell.

@Override
public ItemIdValue fromCell(Cell cell, ExpressionContext ctxt) throws SkipSchemaExpressionException {
    if (cell.recon != null && (Judgment.Matched.equals(cell.recon.judgment) || Judgment.New.equals(cell.recon.judgment))) {
        if (cell.recon.identifierSpace == null || !cell.recon.identifierSpace.equals(ctxt.getBaseIRI())) {
            QAWarning warning = new QAWarning("invalid-identifier-space", null, QAWarning.Severity.INFO, 1);
            warning.setProperty("example_cell", cell.value.toString());
            ctxt.addWarning(warning);
            throw new SkipSchemaExpressionException();
        }
        return new ReconItemIdValue(cell.recon, cell.value.toString());
    }
    throw new SkipSchemaExpressionException();
}
Also used : ReconItemIdValue(org.openrefine.wikidata.schema.entityvalues.ReconItemIdValue) SkipSchemaExpressionException(org.openrefine.wikidata.schema.exceptions.SkipSchemaExpressionException) QAWarning(org.openrefine.wikidata.qa.QAWarning)

Example 2 with ReconItemIdValue

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

the class WbEntityVariableTest method testReconciledItemCell.

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

Example 3 with ReconItemIdValue

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

the class WbEntityVariableTest method testNewItemCell.

@Test
public void testNewItemCell() {
    Recon recon = Recon.makeWikidataRecon(3782378L);
    recon.judgment = Recon.Judgment.New;
    recon.candidates = Collections.singletonList(new ReconCandidate("Q123", "some item", null, 100.0));
    Cell cell = new Cell("some value", recon);
    evaluatesTo(new ReconItemIdValue(recon, "some value"), cell);
}
Also used : ReconItemIdValue(org.openrefine.wikidata.schema.entityvalues.ReconItemIdValue) Recon(com.google.refine.model.Recon) Cell(com.google.refine.model.Cell) ReconCandidate(com.google.refine.model.ReconCandidate) JacksonSerializationTest(org.openrefine.wikidata.testing.JacksonSerializationTest) Test(org.testng.annotations.Test)

Example 4 with ReconItemIdValue

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

the class WbItemVariableTest method testNewItemCell.

@Test
public void testNewItemCell() {
    Recon recon = Recon.makeWikidataRecon(3782378L);
    recon.judgment = Recon.Judgment.New;
    recon.candidates = Collections.singletonList(new ReconCandidate("Q123", "some item", null, 100.0));
    Cell cell = new Cell("some value", recon);
    evaluatesTo(new ReconItemIdValue(recon, "some value"), cell);
}
Also used : ReconItemIdValue(org.openrefine.wikidata.schema.entityvalues.ReconItemIdValue) Recon(com.google.refine.model.Recon) Cell(com.google.refine.model.Cell) ReconCandidate(com.google.refine.model.ReconCandidate) JacksonSerializationTest(org.openrefine.wikidata.testing.JacksonSerializationTest) Test(org.testng.annotations.Test)

Example 5 with ReconItemIdValue

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

the class WbItemVariableTest method testReconciledCell.

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

Aggregations

ReconItemIdValue (org.openrefine.wikidata.schema.entityvalues.ReconItemIdValue)6 Cell (com.google.refine.model.Cell)4 Recon (com.google.refine.model.Recon)4 ReconCandidate (com.google.refine.model.ReconCandidate)4 JacksonSerializationTest (org.openrefine.wikidata.testing.JacksonSerializationTest)4 Test (org.testng.annotations.Test)4 QAWarning (org.openrefine.wikidata.qa.QAWarning)2 SkipSchemaExpressionException (org.openrefine.wikidata.schema.exceptions.SkipSchemaExpressionException)2 ReconMediaInfoIdValue (org.openrefine.wikidata.schema.entityvalues.ReconMediaInfoIdValue)1 ReconPropertyIdValue (org.openrefine.wikidata.schema.entityvalues.ReconPropertyIdValue)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