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>
pids
protected ValueMatcher
valueMatcher
-
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.boolean
equals(Object obj)
Set<String>
getPids()
ValueMatcher
getValueMatcher()
int
hashCode()
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 theValueMatcher
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 theValueMatcher
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 theValueMatcher
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 theValueMatcher
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 theValueMatcher
provided?String
toString()
-
-
-
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:StatementMerger
Determines if the existing statement matches the statement to add (or remove)- Specified by:
match
in 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: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 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 theValueMatcher
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 theValueMatcher
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 theValueMatcher
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 theValueMatcher
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 theValueMatcher
provided?- Parameters:
snak1
-snak2
-- Returns:
-
getValueMatcher
public ValueMatcher getValueMatcher()
-
-