Interface MatchKit
This interface consists of two methods. One tests whether two tuples count as matching or not, and assigns a closeness score if they are (in practice, this is likely to compare corresponding elements of the two submitted tuples allowing for some error in each one). The second is a bit more subtle: it must identify a set of bins into which possible matches for the tuple might fall. For the case of coordinate matching with errors, you would need to chop the whole possible space into a discrete set of zones, each with a given key, and return the key for each zone near enough to the submitted tuple (point) that it might contain a match for it.
Formally, the requirements for correct implementations of this interface are as follows:
matchScore(t1,t2)
==matchScore(t2,t1)
matchScore(t1,t2)>=0
implies a non-zero intersection ofgetBins(t1)
andgetBins(t2)
- the intersection of
getBins(t1)
andgetBins(t2)
is as small as possible for non-matchingt1
andt2
(preferably 0) - the number of bins returned by
getBins
is as small as possible (preferably 1)
It may help to think of all this as a sort of fuzzy hash.
Instances of this class are not thread-safe, and should not be used from multiple threads concurrently.
- Since:
- 9 May 2022
- Author:
- Mark Taylor
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Object[]
Convenience constant - it's a zero-length array of objects, suitable for returning fromgetBins(java.lang.Object[])
if no match can result. -
Method Summary
-
Field Details
-
NO_BINS
Convenience constant - it's a zero-length array of objects, suitable for returning fromgetBins(java.lang.Object[])
if no match can result.
-
-
Method Details
-
getBins
Returns a set of keys for bins into which possible matches for a given tuple might fall. The returned objects can be anything, but should have theirequals
andhashCode
methods implemented properly for comparison.- Parameters:
tuple
- tuple- Returns:
- set of bin keys which might be returned by invoking this
method on other tuples which count as matches for the
submitted
tuple
-
matchScore
Indicates whether two tuples count as matching each other, and if so how closely. Iftuple1
andtuple2
are considered as a matching pair, then a non-negative value should be returned indicating how close the match is - the higher the number the worse the match, and a return value of zero indicates a 'perfect' match. If the two tuples do not consitute a matching pair, then a negative number (conventionally -1.0) should be returned. This return value can be thought of as (and will often correspond physically with) the distance in some real or notional space between the points represented by the two submitted tuples.If there's no reason to do otherwise, the range 0..1 is recommended for successul matches. However, if the result has some sort of physical meaning (such as a distance in real space) that may be used instead.
- Parameters:
tuple1
- one tupletuple2
- the other tuple- Returns:
- 'distance' between
tuple1
andtuple2
; 0 is a perfect match, larger values indicate worse matches, negative values indicate no match
-