README
SIFT 4
npm
Install via$ npm install sift-distance
NOTE: The major version of this module tracks the algorithm's version.
So, if you want to use SIFT 3, for example, you'd install sift-distance@3.0
, for version 3B of the SIFT algorithm sift-distance@3.1
, for version 4 sift-distance@4.0
and so on.
About
This implements the SIFT4 extended version.
API
SIFT( a, b, [options] )
- String|Buffer|Array
a
- String|Buffer|Array
b
- Object
options
- Number
maxOffset
- Number
maxDistance
- Function
tokenizer
- Function
tokenMatcher
- Function
matchEvaluator
- Function
lengthEvaluator
- Function
transpositionEvaluator
- Number
Options
maxOffset
Number The maximum largest common substring offset to be matched against one another. Defaults to 5
.
maxDistance
Number Distance at which the algorithm should stop computing the value and just exit (the values are too different anyway).
tokenizer( value ) -> String|Array|Buffer
Function - Mixed
value
Function to transform strings into vectors of tokens.
tokenMatcher( token1, token2 ) -> Boolean
Function - Mixed
token1
- Mixed
token2
Function to determine if two tokens match each other (equal).
matchEvaluator( token1, token2 ) -> Number
Function - Mixed
token1
- Mixed
token2
Function to determine the way a token match should be added to the lcs
(largest common substring). For example, a fuzzy match could be implemented.
lengthEvaluator( lcs ) -> Number
Function - Number
lcs
: largest common substring length
Function to determine the way the lcs
value is added to the lcss
. For example, longer continuous substrings could be awarded.
transpositionEvaluator( transpositions, lcss ) -> Number
Function - Number
transpositions
: number of transpositions - Number
lcss
: largest common subsequence length
Function to determine the way the number of transpositions affects the final result.