All Projects → stephenjjbrown → string-similarity-js

stephenjjbrown / string-similarity-js

Licence: MIT license
Lightweight string similarity function for javascript

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to string-similarity-js

Awgo
Go library for Alfred 3 + 4 workflows
Stars: ✭ 556 (+1817.24%)
Mutual labels:  fuzzy-search, fuzzy
Fuzzy
Go library that provides fuzzy string matching optimized for filenames and code symbols in the style of Sublime Text, VSCode, IntelliJ IDEA et al.
Stars: ✭ 979 (+3275.86%)
Mutual labels:  fuzzy-search, fuzzy
Fz
Cli shell plugin, the missing fuzzy tab completion feature of z jump around command.
Stars: ✭ 359 (+1137.93%)
Mutual labels:  fuzzy-search, fuzzy
Alfred Fuzzy
Fuzzy search helper for Alfred 3+ workflows
Stars: ✭ 67 (+131.03%)
Mutual labels:  fuzzy-search, fuzzy
Fzy
🔍 A simple, fast fuzzy finder for the terminal
Stars: ✭ 2,295 (+7813.79%)
Mutual labels:  fuzzy-search, fuzzy
Fuzzy Swift
🔍 simple and fast fuzzy string matching in Swift
Stars: ✭ 61 (+110.34%)
Mutual labels:  string, fuzzy
Flexsearch
Next-Generation full text search library for Browser and Node.js
Stars: ✭ 8,108 (+27858.62%)
Mutual labels:  fuzzy-search, fuzzy
Fzy.js
A javascript port of fzy's scoring algorithm. As seen on GitHub.com!
Stars: ✭ 82 (+182.76%)
Mutual labels:  fuzzy-search, fuzzy
Leaderf
An efficient fuzzy finder that helps to locate files, buffers, mrus, gtags, etc. on the fly for both vim and neovim.
Stars: ✭ 1,733 (+5875.86%)
Mutual labels:  fuzzy-search, fuzzy
Tntsearch
A fully featured full text search engine written in PHP
Stars: ✭ 2,693 (+9186.21%)
Mutual labels:  fuzzy-search, fuzzy
strutil
Golang metrics for calculating string similarity and other string utility functions
Stars: ✭ 114 (+293.1%)
Mutual labels:  string, string-similarity
AgileStringDecryptor
a dynamic Agile.NET string decryptor that relies on invoke by wwh1004 | Version : 6.X
Stars: ✭ 24 (-17.24%)
Mutual labels:  string
tlsh
TLSH lib in Golang
Stars: ✭ 110 (+279.31%)
Mutual labels:  fuzzy
itunes-cli
Command line interface for control iTunes
Stars: ✭ 16 (-44.83%)
Mutual labels:  fuzzy-search
fzfx
fzfX delivers the power of finding, previewing, editing and managing any file in few key strokes.
Stars: ✭ 71 (+144.83%)
Mutual labels:  fuzzy
bolt.nvim
⚡ Ultrafast multi-pane file manager for Neovim with fuzzy matching
Stars: ✭ 100 (+244.83%)
Mutual labels:  fuzzy-search
compact str
A memory efficient string type that can store up to 24* bytes on the stack
Stars: ✭ 322 (+1010.34%)
Mutual labels:  string
comment-mark
Interpolate strings with HTML comment markers!
Stars: ✭ 21 (-27.59%)
Mutual labels:  string
algos
A collection of algorithms in rust
Stars: ✭ 16 (-44.83%)
Mutual labels:  string-match
MGObfuscator
An easy encryptor / decryptor for iOS
Stars: ✭ 17 (-41.38%)
Mutual labels:  string

Build Status codecov Wallaby.js Codacy Badge

String Similarity

A simple, lightweight (~700 bytes minified) string similarity function based on comparing the number of bigrams in common between any two strings. Returns a score between 0 and 1 indicating the strength of the match.

Based on the Sørensen–Dice coefficient, this algorithm is most effective at detecting rearranged words or misspellings. It tends to be less effective with very short strings, unless perhaps you switch to comparing individual characters in common instead of bigrams.

It is case insensitive unless you specify otherwise. Does not ignore punctuation or spaces. In some cases, removing punctuation beforehand may improve accuracy.

Update

Version 2.0 optimizes the algorithm from O(n2) time complexity to O(n), and switches from using an array for bigrams to a Map, which was found to be substantially faster in performance tests.

Usage

Requirements

This library uses built-in Map data structure for optimal performance. Therefore, it requires at least IE11 or a polyfill for Map.

Examples

import { stringSimilarity } from "string-similarity-js";

// Rearranged words
stringSimilarity("Lorem ipsum", "Ipsum lorem")
// Returns a score of 0.9

// Typos
stringSimilarity("The quick brown fox jumps over the lazy dog", "The quck brown fx jumps over the lazy dog")
// 0.92

// Even more different
stringSimilarity("The quick brown fox jumps over the lazy dog", "The quack brain fax jomps odor the lady frog")
// 0.65

// Completely different strings
stringSimilarity("The quick brown fox jumps over the lazy dog", "Lorem ipsum")
// 0.07

// Tiny strings are less effective with default settings
stringSimilarity("DMV", "DNV")
// Returns 0, because technically there are no bigrams in common between the two

// Passing in a substring length of 1 may improve accuracy on tiny strings
stringSimilarity("DMV", "DNV", 1)
// Returns 0.67, the percentage of letters in common between the two

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].