tripokey/elm-fuzzy/3.0.0

NOTE: this package is not compatible with Elm 0.19.1

Fuzzy

This is library for performing fuzzy string matching.

Matching

match : List String -> List String -> Int

Perform fuzzy matching between a List String (needle) and another List String (hay). The order of the arguments are significant. Lower score is better. Each element in the Lists represents one "word".

let
    query = "/usr/lcoa/bin/sh"
    target = "/usr/local/bin/sh"
    sep = "/"
in
    Fuzzy.match (String.split sep query) (String.split sep hay) == 101


Fuzzy.match ["test"] ["test]" == 0
Fuzzy.match ["tst"] ["test"] == 1
Fuzzy.match ["test"] ["tste"] == 100
Fuzzy.match ["test"] ["tst"] == 1000
List.sortBy (\hay -> Fuzzy.match ["hrdevi"] [hay]) ["screen", "disk", "harddrive", "keyboard", "mouse", "computer"] == ["harddrive","keyboard","disk","screen","computer","mouse"]