Class QualifiersStatementMerger

java.lang.Object
org.openrefine.wikidata.schema.strategies.QualifiersStatementMerger
All Implemented Interfaces:
StatementMerger

public class QualifiersStatementMerger extends Object implements StatementMerger
Merging strategy which compares statements using not just their main value, but also their qualifiers. It is possible to specify the pids of the qualifiers to take into account when comparing statements.
Author:
Antonin Delpeuch
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final Set<String>
     
    protected final ValueMatcher
     

    Fields inherited from interface org.openrefine.wikidata.schema.strategies.StatementMerger

    FORMER_DEFAULT_STRATEGY
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    List<org.wikidata.wdtk.datamodel.interfaces.SnakGroup>
    discriminatingSnaks(List<org.wikidata.wdtk.datamodel.interfaces.SnakGroup> snaks)
    Given a list of qualifiers, extract the discriminating ones.
    boolean
     
     
     
    int
     
    boolean
    match(org.wikidata.wdtk.datamodel.interfaces.Statement existing, org.wikidata.wdtk.datamodel.interfaces.Statement added)
    Determines if the existing statement matches the statement to add (or remove)
    org.wikidata.wdtk.datamodel.interfaces.Statement
    merge(org.wikidata.wdtk.datamodel.interfaces.Statement existing, org.wikidata.wdtk.datamodel.interfaces.Statement added)
    Return the result of merging the statement to add with the existing statement.
    protected org.wikidata.wdtk.datamodel.interfaces.SnakGroup
    mergeSnakGroups(org.wikidata.wdtk.datamodel.interfaces.SnakGroup snakGroup1, org.wikidata.wdtk.datamodel.interfaces.SnakGroup snakGroup2)
    Merge two snak groups, ensuring no duplicate snak appears with respect to the ValueMatcher provided.
    protected boolean
    snakEquality(org.wikidata.wdtk.datamodel.interfaces.Snak snak1, org.wikidata.wdtk.datamodel.interfaces.Snak snak2)
    Are these two snaks equal up to the ValueMatcher provided?
    protected boolean
    snakGroupEquality(org.wikidata.wdtk.datamodel.interfaces.SnakGroup snakGroup1, org.wikidata.wdtk.datamodel.interfaces.SnakGroup snakGroup2)
    Are these two snak groups equal up to the ValueMatcher provided?
    protected boolean
    snakGroupsEqual(List<org.wikidata.wdtk.datamodel.interfaces.SnakGroup> snakGroups1, List<org.wikidata.wdtk.datamodel.interfaces.SnakGroup> snakGroups2)
    Are these lists of snak groups equal up to the ValueMatcher provided?
    protected boolean
    snakGroupsIncluded(List<org.wikidata.wdtk.datamodel.interfaces.SnakGroup> snakGroups1, List<org.wikidata.wdtk.datamodel.interfaces.SnakGroup> snakGroups2)
    Is the first list of snak groups included in the second one?
    protected boolean
    snaksIncluded(List<org.wikidata.wdtk.datamodel.interfaces.Snak> snaks1, List<org.wikidata.wdtk.datamodel.interfaces.Snak> snaks2)
    Is this list of snak included in the other, up to the ValueMatcher provided?
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • QualifiersStatementMerger

      public QualifiersStatementMerger(ValueMatcher valueMatcher, Set<String> pids)
  • Method Details

    • match

      public boolean match(org.wikidata.wdtk.datamodel.interfaces.Statement existing, org.wikidata.wdtk.datamodel.interfaces.Statement added)
      Description copied from interface: StatementMerger
      Determines if the existing statement matches the statement to add (or remove)
      Specified by:
      match in interface StatementMerger
      Parameters:
      existing - the statement currently on the entity
      added - the statement to add or remove
      Returns:
    • merge

      public org.wikidata.wdtk.datamodel.interfaces.Statement merge(org.wikidata.wdtk.datamodel.interfaces.Statement existing, org.wikidata.wdtk.datamodel.interfaces.Statement added)
      Description copied from interface: StatementMerger
      Return the result of merging the statement to add with the existing statement. This method can assume that the two statements are matching (i.e. the method above has returned true on them).
      Specified by:
      merge in interface StatementMerger
      Parameters:
      existing - the statement currently on the entity
      added - the statement to add or remove
      Returns:
      the merged statement obtained out of the two
    • mergeSnakGroups

      protected org.wikidata.wdtk.datamodel.interfaces.SnakGroup mergeSnakGroups(org.wikidata.wdtk.datamodel.interfaces.SnakGroup snakGroup1, org.wikidata.wdtk.datamodel.interfaces.SnakGroup snakGroup2)
      Merge two snak groups, ensuring no duplicate snak appears with respect to the ValueMatcher provided.
      Parameters:
      snakGroup1 -
      snakGroup2 -
      Returns:
    • discriminatingSnaks

      public List<org.wikidata.wdtk.datamodel.interfaces.SnakGroup> discriminatingSnaks(List<org.wikidata.wdtk.datamodel.interfaces.SnakGroup> snaks)
      Given a list of qualifiers, extract the discriminating ones.
    • snakGroupsEqual

      protected boolean snakGroupsEqual(List<org.wikidata.wdtk.datamodel.interfaces.SnakGroup> snakGroups1, List<org.wikidata.wdtk.datamodel.interfaces.SnakGroup> snakGroups2)
      Are these lists of snak groups equal up to the ValueMatcher provided?
    • snakGroupsIncluded

      protected boolean snakGroupsIncluded(List<org.wikidata.wdtk.datamodel.interfaces.SnakGroup> snakGroups1, List<org.wikidata.wdtk.datamodel.interfaces.SnakGroup> snakGroups2)
      Is the first list of snak groups included in the second one?
    • snakGroupEquality

      protected boolean snakGroupEquality(org.wikidata.wdtk.datamodel.interfaces.SnakGroup snakGroup1, org.wikidata.wdtk.datamodel.interfaces.SnakGroup snakGroup2)
      Are these two snak groups equal up to the ValueMatcher provided?
      Parameters:
      snakGroup1 -
      snakGroup2 -
      Returns:
    • snaksIncluded

      protected boolean snaksIncluded(List<org.wikidata.wdtk.datamodel.interfaces.Snak> snaks1, List<org.wikidata.wdtk.datamodel.interfaces.Snak> snaks2)
      Is this list of snak included in the other, up to the ValueMatcher provided?
      Parameters:
      snaks1 -
      snaks2 -
      Returns:
    • snakEquality

      protected boolean snakEquality(org.wikidata.wdtk.datamodel.interfaces.Snak snak1, org.wikidata.wdtk.datamodel.interfaces.Snak snak2)
      Are these two snaks equal up to the ValueMatcher provided?
      Parameters:
      snak1 -
      snak2 -
      Returns:
    • getValueMatcher

      public ValueMatcher getValueMatcher()
    • getPids

      public Set<String> getPids()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object