Search in sources :

Example 1 with SomeValueSnak

use of org.wikidata.wdtk.datamodel.interfaces.SomeValueSnak in project OpenRefine by OpenRefine.

the class SnakOnlyStatementMerger method match.

/**
 * Matches two snaks using the underlying value matcher.
 * The snaks must have the same property id to match.
 *
 * @param existingSnak
 * @param addedSnak
 * @return
 */
public boolean match(Snak existingSnak, Snak addedSnak) {
    // Deliberately only comparing the pids and not the siteIRIs to avoid spurious mismatches due to federation
    if (!existingSnak.getPropertyId().getId().equals(addedSnak.getPropertyId().getId())) {
        return false;
    } else if (existingSnak instanceof NoValueSnak && addedSnak instanceof NoValueSnak) {
        return true;
    } else if (existingSnak instanceof SomeValueSnak && addedSnak instanceof SomeValueSnak) {
        return true;
    } else {
        Value existingValue = ((ValueSnak) existingSnak).getValue();
        Value addedValue = ((ValueSnak) addedSnak).getValue();
        return valueMatcher.match(existingValue, addedValue);
    }
}
Also used : NoValueSnak(org.wikidata.wdtk.datamodel.interfaces.NoValueSnak) Value(org.wikidata.wdtk.datamodel.interfaces.Value) SomeValueSnak(org.wikidata.wdtk.datamodel.interfaces.SomeValueSnak) SomeValueSnak(org.wikidata.wdtk.datamodel.interfaces.SomeValueSnak) ValueSnak(org.wikidata.wdtk.datamodel.interfaces.ValueSnak) NoValueSnak(org.wikidata.wdtk.datamodel.interfaces.NoValueSnak)

Aggregations

NoValueSnak (org.wikidata.wdtk.datamodel.interfaces.NoValueSnak)1 SomeValueSnak (org.wikidata.wdtk.datamodel.interfaces.SomeValueSnak)1 Value (org.wikidata.wdtk.datamodel.interfaces.Value)1 ValueSnak (org.wikidata.wdtk.datamodel.interfaces.ValueSnak)1