Skip to content

Word compare gives you the most closely related words to an input string. If you have a list of strings, word compare can give you the most closely related list elements to a string input.

VOYAGERX013/levenshtein-word-compare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Installation

Install word-compare with npm

  npm i word-compare

Documentation

You must import the authjs after installing the package:

const word = require("word-compare");

Say we want to create a search bar that searches movie names stored in an array based on the input given in the bar.

You can now compare the similarity of words easily with word-compare

const movies = ["Interstellar", "Inception", "Matrix", "Iron man", "Shawshank redemption", "Matrix 2"];
const stringInput = "Matrix";

const similarMovies = word.getClosests(stringInput, movies);

console.log(similarMovies); // The following output is logged: [ 'Matrix', 'Matrix 2', 'Iron man', 'Inception', 'Interstellar']

By default word-compare restricts the output to an array with a maximum of five elements. However, you can set this value as a third parameter:

const movies = ["Interstellar", "Inception", "Matrix", "Iron man", "Shawshank redemption", "Matrix 2"];
const stringInput = "Matrix";

const similarMovies = word.getClosests(stringInput, movies, 6);

console.log(similarMovies); // The following output is logged: [ 'Matrix', 'Matrix 2', 'Iron man', 'Inception', 'Interstellar', 'Shawshank redemption' ]

Authors

About

Word compare gives you the most closely related words to an input string. If you have a list of strings, word compare can give you the most closely related list elements to a string input.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published