Skip to content

v2.2.0

Choose a tag to compare

@Tfoucher5 Tfoucher5 released this 26 Nov 14:47
· 65 commits to master since this release
e9a0ae2

v2.2.0

Added

  • fuzzy-toolkit/string-similarity: drop-in replacement for the unmaintained string-similarity package. compareTwoStrings() and findBestMatch() give the same results; only the import changes.
  • Classic metrics: dice(), jaccard(), cosine() (on chunks of n letters), hamming() and lcs() (longest common subsequence).
  • Nested keys: keys: ['artist.name', 'tags.label'], arrays included, checked by TypeScript.
  • includeMatches option of search(), closest() and indexes: each result gets key (the property that matched) and ranges (the parts of text to highlight, to the character: New Yo|rk).
  • acronyms option, on with the search preset: nyc finds New York City, one typo allowed from 3 letters on.
  • index.toJSON() and loadIndex(): save an index as JSON and load it 2.5 times faster than rebuilding it.
  • fingerprint() and group/dedupe method: 'fingerprint': instant grouping of texts with the same words in any order.
  • levenshtein(a, b, { max }) and damerau(a, b, { max }): stop early above a distance.
  • More metrics: jaro(), overlap(), tversky(), ratcliffObershelp() (Python's difflib ratio).
  • fuzzy-toolkit/react: useFuzzySearch() and <Highlight>. React is an optional peer dependency.
  • Minified browser builds for CDNs: <script src="https://cdn.jsdelivr.net/npm/fuzzy-toolkit"> gives fuzzyToolkit. npm run size reports what each import weighs.
  • npm run bench:versus: speed and accuracy against string-similarity, Fuse.js, fuzzysort and fastest-levenshtein on public data. See Compared with other libraries.
  • llms.txt in the package and the repository, so AI coding assistants know the API.
  • Extension API: defineLanguage() and definePreset(). Anyone can write a language pack (numbers in words, articles, stop words, phonetic rules) or a preset for one kind of data, and publish it on npm. See Languages and presets.
  • languages option: ['en', 'fr'] by default, built-in codes or packs.
  • stopwords option: ignore the stop words of the active languages.
  • stripPatterns option: your own regular expressions of noise to remove.
  • preset accepts a preset made with definePreset(), which can extends a built-in one.
  • fuzzy-toolkit/lang/en and fuzzy-toolkit/lang/fr: the built-in packs, to extend or read as examples.
  • CLI: --preset takes a package or a file, --lang picks languages.

Changed

  • English, French and the music, search and strict presets now run on the extension API. Results are identical: checked on 320,000 comparisons of real data against the previous code. The bundle grows by about 1.4 kB (min+gzip) for similarity.
  • ResolvedOptions.preset is now the preset's name as a string, built-in or not.

Faster

  • levenshtein() and damerau() on texts over 32 characters: blocked bit-parallel algorithms, 15 to 25 times faster, on par with fastest-levenshtein.
  • Searching skips items that lack too many of the query's letters, with the same results: up to 2.3 times faster.
  • compareTwoStrings/dice() 2.2 times faster than string-similarity, findBestMatch 3.5 times.
  • dedupe(), group() and join() skip pairs that cannot match, with the same results: 3 to 5 times faster on real lists (5,000 song titles: 4.5 s → 1 s). The command line tool benefits too.