@Override public double score(LocalId candidate, Map<String, String> row, Geometry geometry) throws DaoException { for (WikidataStatement st : wikidataDao.getStatements(candidate.asLocalPage())) { if (st.getProperty() == null || st.getProperty().getId() != INSTANCE_OF_PROPERTY) { continue; } if (st.getValue().getType() == WikidataValue.Type.ITEM) { String name = getPropertyName(st.getValue().getIntValue()); if (name != null && instanceOfKeywords.contains(name.toLowerCase())) { return 1.0; } } } return 0.0; }
@Override public double score(LocalId candidate, Map<String, String> row, Geometry geometry) throws DaoException { for (WikidataStatement st : wikidataDao.getStatements(candidate.asLocalPage())) { if (st.getProperty() == null || st.getProperty().getId() != INSTANCE_OF_PROPERTY) { continue; } if (st.getValue().getType() == WikidataValue.Type.ITEM) { String name = getPropertyName(st.getValue().getIntValue()); if (name != null && instanceOfKeywords.contains(name.toLowerCase())) { return 1.0; } } } return 0.0; }
@Override public double score(LocalId candidate, Map<String, String> row, Geometry geometry) throws DaoException { for (WikidataStatement st : wikidataDao.getStatements(candidate.asLocalPage())) { if (st.getProperty() == null || st.getProperty().getId() != COORDINATE_PROPERTY) { continue; } Geometry point = WikiBrainSpatialUtils.jsonToGeometry(st.getValue().getJsonValue().getAsJsonObject()); if (point != null && geometry.contains(point)) { return 1.0; } } return 0.0; } }
@Override public double score(LocalId candidate, Map<String, String> row, Geometry geometry) throws DaoException { for (WikidataStatement st : wikidataDao.getStatements(candidate.asLocalPage())) { if (st.getProperty() == null || st.getProperty().getId() != COORDINATE_PROPERTY) { continue; } Geometry point = WikiBrainSpatialUtils.jsonToGeometry(st.getValue().getJsonValue().getAsJsonObject()); if (point != null && geometry.contains(point)) { return 1.0; } } return 0.0; } }
@Override public double score(LocalId candidate, Map<String, String> row, Geometry geometry) throws DaoException { if (!row.containsKey(columnName)) { throw new IllegalArgumentException("No column with name " + columnName + " in dbx"); } String rowValue = row.get(columnName).toString(); for (WikidataStatement st : wikidataDao.getStatements(candidate.asLocalPage())) { if (st.getProperty() == null || st.getProperty().getId() != propertyId) { continue; } String candidateVal = null; if (st.getValue().getType() == WikidataValue.Type.ITEM) { candidateVal = String.valueOf(st.getValue().getItemValue()); } else if (st.getValue().getType() == WikidataValue.Type.INT) { candidateVal = String.valueOf(st.getValue().getIntValue()); } else if (st.getValue().getType() == WikidataValue.Type.STRING) { candidateVal = st.getValue().getStringValue(); } else { LOG.warn("Unexpected type for property " + st.getProperty() + ": " + st.getValue()); } if (candidateVal != null && candidateVal.equalsIgnoreCase(rowValue)) { return 1.0; } } return 0.0; } }
@Override public double score(LocalId candidate, Map<String, String> row, Geometry geometry) throws DaoException { if (!row.containsKey(columnName)) { throw new IllegalArgumentException("No column with name " + columnName + " in dbx"); } String rowValue = row.get(columnName).toString(); for (WikidataStatement st : wikidataDao.getStatements(candidate.asLocalPage())) { if (st.getProperty() == null || st.getProperty().getId() != propertyId) { continue; } String candidateVal = null; if (st.getValue().getType() == WikidataValue.Type.ITEM) { candidateVal = String.valueOf(st.getValue().getItemValue()); } else if (st.getValue().getType() == WikidataValue.Type.INT) { candidateVal = String.valueOf(st.getValue().getIntValue()); } else if (st.getValue().getType() == WikidataValue.Type.STRING) { candidateVal = st.getValue().getStringValue(); } else { LOG.warn("Unexpected type for property " + st.getProperty() + ": " + st.getValue()); } if (candidateVal != null && candidateVal.equalsIgnoreCase(rowValue)) { return 1.0; } } return 0.0; } }