Skip to content

Latest commit

 

History

History
14 lines (11 loc) · 719 Bytes

README.markdown

File metadata and controls

14 lines (11 loc) · 719 Bytes

DidYouMean.js

DidYouMean takes a query and returns similar words based on a dictionary of words that you feed it.

Demo

Take a look at the demo

Example usage

var dym = new DidYouMean(['hello', 'goodbye']);
var suggestions = dym.query('helo'); // this returns ['hello']

Implementation

A BK-Tree is created with your dictionary words as nodes. When queried, it uses Levenshtein Distance to compare how similar your query is to the words in the tree. If a word is within a certain edit distance threshold (default: 2), it's returned as a suggestion.