Class QualifiersStatementMerger
- java.lang.Object
-
- org.openrefine.wikibase.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 Set<String>pidsprotected ValueMatchervalueMatcher-
Fields inherited from interface org.openrefine.wikibase.schema.strategies.StatementMerger
FORMER_DEFAULT_STRATEGY
-
-
Constructor Summary
Constructors Constructor Description QualifiersStatementMerger(ValueMatcher valueMatcher, Set<String> pids)
-
Method Summary
All Methods Instance Methods Concrete Methods 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.booleanequals(Object obj)Set<String>getPids()ValueMatchergetValueMatcher()inthashCode()booleanmatch(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.Statementmerge(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.SnakGroupmergeSnakGroups(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 theValueMatcherprovided.protected booleansnakEquality(org.wikidata.wdtk.datamodel.interfaces.Snak snak1, org.wikidata.wdtk.datamodel.interfaces.Snak snak2)Are these two snaks equal up to theValueMatcherprovided?protected booleansnakGroupEquality(org.wikidata.wdtk.datamodel.interfaces.SnakGroup snakGroup1, org.wikidata.wdtk.datamodel.interfaces.SnakGroup snakGroup2)Are these two snak groups equal up to theValueMatcherprovided?protected booleansnakGroupsEqual(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 theValueMatcherprovided?protected booleansnakGroupsIncluded(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 booleansnaksIncluded(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 theValueMatcherprovided?StringtoString()
-
-
-
Field Detail
-
valueMatcher
protected final ValueMatcher valueMatcher
-
-
Constructor Detail
-
QualifiersStatementMerger
public QualifiersStatementMerger(ValueMatcher valueMatcher, Set<String> pids)
-
-
Method Detail
-
match
public boolean match(org.wikidata.wdtk.datamodel.interfaces.Statement existing, org.wikidata.wdtk.datamodel.interfaces.Statement added)Description copied from interface:StatementMergerDetermines if the existing statement matches the statement to add (or remove)- Specified by:
matchin interfaceStatementMerger- Parameters:
existing- the statement currently on the entityadded- 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:StatementMergerReturn 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:
mergein interfaceStatementMerger- Parameters:
existing- the statement currently on the entityadded- 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 theValueMatcherprovided.- 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 theValueMatcherprovided?
-
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 theValueMatcherprovided?- 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 theValueMatcherprovided?- 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 theValueMatcherprovided?- Parameters:
snak1-snak2-- Returns:
-
getValueMatcher
public ValueMatcher getValueMatcher()
-
-