close-word
v1.2.1
Published
this module will help to find the closest word from given set of words
Downloads
6
Readme
Introduction
get closest word for a specific word from given set of word list
installation
npm i close-word --save
Code sample to find closest word
var word_finder = require('close-word')
var result = word_finder.findClosestOne('newbyrork',['new york','new delhi','kandy','paris','new jersey','london','colombo','jafna']);
console.log(result); // result = { word: 'new york', score: 397.6190476190476 }
Code sample to find 5 closest words
var word_finder = require('close-word');
var result = word_finder.findClosestFive('newbyrork',['new york','new delhi','kandy','paris','new jersey','london','colombo','jafna']);
console.log(result);
/*
result = [
{ word: 'new york', score: 397.6190476190476 },
{ word: 'new jersey', score: 216.39344262295083 },
{ word: 'new delhi', score: 166.39344262295083 },
{ word: 'kandy', score: 112.34567901234568 },
{ word: 'london', score: 112.34567901234568 }
] */
Code sample to find any number closest words according to the 3rd param you given to the function.in this case 3
var word_finder = require('close-word');
var result = word_finder.findClosestAny('newbyrork',['new york','new delhi','kandy','paris','new jersey','london','colombo','jafna'], 3 );
console.log(result);
/*
result = [
{ word: 'new york', score: 397.6190476190476 },
{ word: 'new jersey', score: 216.39344262295083 },
{ word: 'new delhi', score: 166.39344262295083 }
]*/