lingoe
v1.0.0
Published
Word search algorithms
Downloads
3
Maintainers
Readme
Lingoe
Word search algorithms
Install
Node.js
npm install lingoe
Usage
Add node module
const Lingoe = require('lingoe');
Trie
let trie = new Lingoe.Trie();
let words = ['word', 'the', 'apple', 'there', 'ape', 'bananas'];
for (let i in words) {
trie.add(words[i]);
}
console.log(trie.contains('apple'));
// outputs true
console.log(trie.prefixes('ap'));
// outputs ['apple', 'ape']
console.log(trie.words());
// outputs ['word', 'the', 'apple', 'there', 'ape', 'bananas']
Levenshtien Distance
console.log(Lingoe.distance('kitten', 'sitting'));
// outputs 3
Levenshtien Distance Ratio
console.log(Lingoe.ratio('flaw', 'lawn'));
// outputs 0.5