Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

didyoumean2

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

didyoumean2

a library for matching human-quality input to a list of potential matches using the Levenshtein distance algorithm

  • 7.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
124K
decreased by-10.97%
Maintainers
1
Weekly downloads
 
Created

What is didyoumean2?

The didyoumean2 npm package is a utility for suggesting corrections to misspelled words or phrases. It is particularly useful for command-line interfaces, chatbots, and other applications where user input may contain typos. The package uses a combination of string similarity algorithms to provide the best possible suggestions.

What are didyoumean2's main functionalities?

Basic Usage

This feature allows you to provide a list of possible correct words and get suggestions based on the input. In this example, 'appl' is corrected to 'apple'.

const didYouMean = require('didyoumean2');
const input = 'appl';
const suggestions = didYouMean(input, ['apple', 'banana', 'grape']);
console.log(suggestions); // Output: ['apple']

Custom Threshold

This feature allows you to set a custom threshold for the similarity score. The threshold determines how close the input needs to be to the suggestions. In this example, a threshold of 0.4 is used.

const didYouMean = require('didyoumean2');
const input = 'appl';
const options = { threshold: 0.4 };
const suggestions = didYouMean(input, ['apple', 'banana', 'grape'], options);
console.log(suggestions); // Output: ['apple']

Multiple Suggestions

This feature allows you to get multiple suggestions instead of just the best match. In this example, both 'apple' and 'applet' are returned as suggestions for 'appl'.

const didYouMean = require('didyoumean2');
const input = 'appl';
const options = { returnType: 'all-matches' };
const suggestions = didYouMean(input, ['apple', 'applet', 'banana', 'grape'], options);
console.log(suggestions); // Output: ['apple', 'applet']

Other packages similar to didyoumean2

Keywords

FAQs

Package last updated on 17 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc