diff --git a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbLanguageVariable.java b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbLanguageVariable.java index 081019e5b..1b7cba60b 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbLanguageVariable.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbLanguageVariable.java @@ -1,6 +1,7 @@ package org.openrefine.wikidata.schema; import org.openrefine.wikidata.schema.exceptions.SkipSchemaExpressionException; +import org.wikidata.wdtk.datamodel.interfaces.WikimediaLanguageCodes; import com.google.refine.model.Cell; @@ -13,8 +14,14 @@ public class WbLanguageVariable extends WbVariableExpr { public String fromCell(Cell cell, ExpressionContext ctxt) throws SkipSchemaExpressionException { if (cell.value != null && !cell.value.toString().isEmpty()) { - // TODO some validation here? - return cell.value.toString(); + String code = cell.value.toString().trim(); + try { + // this just checks that the language code is known + WikimediaLanguageCodes.getLanguageCode(code); + return cell.value.toString(); + } catch(IllegalArgumentException e) { + ; + } } throw new SkipSchemaExpressionException(); } diff --git a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbLocationConstant.java b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbLocationConstant.java index e8e4476fd..78d0075f2 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbLocationConstant.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbLocationConstant.java @@ -12,6 +12,8 @@ import com.fasterxml.jackson.annotation.JsonProperty; public class WbLocationConstant implements WbExpression { + public static final double defaultPrecision = GlobeCoordinatesValue.PREC_TEN_MICRO_DEGREE; + private String value; private GlobeCoordinatesValue parsed; @@ -29,7 +31,7 @@ public class WbLocationConstant implements WbExpression { public static GlobeCoordinatesValue parse(String expr) throws ParseException { double lat = 0; double lng = 0; - double precision = GlobeCoordinatesValue.PREC_TEN_MICRO_DEGREE; + double precision = defaultPrecision; String[] parts = expr.split("[,/]"); if (parts.length >= 2 && parts.length <= 3) { try {