1.0.0 • Published 6 years ago

lingoe v1.0.0

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

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