This is library for performing fuzzy string matching.
Create a penalty configuration that is applied to each additional character in needle.
Create a penalty configuration that is applied to each out of order character in hay.
Perform fuzzy matching between a query String (needle) and a target String (hay). The order of the arguments are significant. Lower score is better. Specifying some separators will allow for partial matching within a sentence. The default configuration is movePenalty = 100, addPenalty = 1, removePenalty = 1000.
let
simpleMatch config separators needle hay =
match config separators needle hay |> .score
in
simpleMatch [] [] "test" "test" == 0
simpleMatch [] [] "tst" "test" == 1
simpleMatch [addPenalty 10000] [] "tst" "test" == 10000
simpleMatch [] [] "test" "tste" == 100
simpleMatch [] [] "test" "tst" == 1000
simpleMatch [] ["/"] "/u/b/s" "/usr/local/bin/sh" == 5
simpleMatch [] [] "/u/b/s" "/usr/local/bin/sh" == 211
List.sortBy (simpleMatch [] [] "hrdevi") ["screen", "disk", "harddrive", "keyboard", "mouse", "computer"] == ["harddrive","keyboard","disk","screen","computer","mouse"]Represents the result of a match. score is the total score of the result. matches is a list of matching words within the hay.
Represents a matching word in hay. score is the score that this Match contributes to the total score in a Result. offset is the index where this match starts in the hay. length is the length of the match. keys is a list of matching indexes within the word. The keys are relative to the offset.
Represents a matching character in a Match.
Create a penalty configuration that is applied to each additional character in hay.