Refuse reconciled cells with invalid space
This commit is contained in:
parent
d6232efd95
commit
0c21d6d171
@ -193,6 +193,10 @@
|
|||||||
"non-printable-characters": {
|
"non-printable-characters": {
|
||||||
"title": "Non-printable characters in strings.",
|
"title": "Non-printable characters in strings.",
|
||||||
"body": "Strings such as <span class=\"wb-issue-preformat\">{example_string}</span> contain non-printable characters."
|
"body": "Strings such as <span class=\"wb-issue-preformat\">{example_string}</span> contain non-printable characters."
|
||||||
|
},
|
||||||
|
"invalid-identifier-space": {
|
||||||
|
"title": "Invalid identifier space for reconciled cells.",
|
||||||
|
"body": "Some reconciled cells such as <span class=\"wb-issue-preformat\">{example_cell}</span> were ignored because they are not reconciled to Wikidata."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,10 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package org.openrefine.wikidata.schema;
|
package org.openrefine.wikidata.schema;
|
||||||
|
|
||||||
|
import org.openrefine.wikidata.qa.QAWarning;
|
||||||
import org.openrefine.wikidata.schema.entityvalues.ReconItemIdValue;
|
import org.openrefine.wikidata.schema.entityvalues.ReconItemIdValue;
|
||||||
import org.openrefine.wikidata.schema.exceptions.SkipSchemaExpressionException;
|
import org.openrefine.wikidata.schema.exceptions.SkipSchemaExpressionException;
|
||||||
|
import org.wikidata.wdtk.datamodel.helpers.Datamodel;
|
||||||
import org.wikidata.wdtk.datamodel.interfaces.ItemIdValue;
|
import org.wikidata.wdtk.datamodel.interfaces.ItemIdValue;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
@ -61,6 +63,12 @@ public class WbItemVariable extends WbVariableExpr<ItemIdValue> {
|
|||||||
throws SkipSchemaExpressionException {
|
throws SkipSchemaExpressionException {
|
||||||
if (cell.recon != null
|
if (cell.recon != null
|
||||||
&& (Judgment.Matched.equals(cell.recon.judgment) || Judgment.New.equals(cell.recon.judgment))) {
|
&& (Judgment.Matched.equals(cell.recon.judgment) || Judgment.New.equals(cell.recon.judgment))) {
|
||||||
|
if (!cell.recon.identifierSpace.equals(Datamodel.SITE_WIKIDATA)) {
|
||||||
|
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());
|
return new ReconItemIdValue(cell.recon, cell.value.toString());
|
||||||
}
|
}
|
||||||
throw new SkipSchemaExpressionException();
|
throw new SkipSchemaExpressionException();
|
||||||
|
@ -67,6 +67,16 @@ public class WbItemVariableTest extends WbVariableTest<ItemIdValue> {
|
|||||||
Cell cell = new Cell("some value", recon);
|
Cell cell = new Cell("some value", recon);
|
||||||
isSkipped(cell);
|
isSkipped(cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInvalidSpace() {
|
||||||
|
Recon recon = Recon.makeWikidataRecon(34989L);
|
||||||
|
recon.identifierSpace = "http://my.own.wikiba.se/";
|
||||||
|
recon.candidates = Collections.singletonList(new ReconCandidate("Q123", "some item", null, 100.0));
|
||||||
|
recon.judgment = Recon.Judgment.Matched;
|
||||||
|
Cell cell = new Cell("some value", recon);
|
||||||
|
isSkipped(cell);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnreconciledCell() {
|
public void testUnreconciledCell() {
|
||||||
|
Loading…
Reference in New Issue
Block a user