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

micro-spelling-correcter

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

micro-spelling-correcter

Simple breadth-first early terminating Levenshtein distance auto correcter for small sets of possible resulting strings.

  • 1.1.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
145K
increased by7.71%
Maintainers
1
Weekly downloads
 
Created
Source

micro-spelling-correcter Build Status codecov

Simple breadth-first early terminating Levenshtein distance auto correcter for small sets of possible resulting strings.

Finds first suiting correction for word if there is one with distance less or equal than target maximum distance and returns it, otherwise returns undefined.

Additionally, applies a simple heuristic of limiting max distance to half input length rounded down but not lessser than one, which helps to escape corrections which feel weird in real life(like 'a' => 'is', 'foo' => 'log' with distance 2).

Details:

  • Cost of every edit is counted as 1, though for every analyzed distance search tries skips then replacements then transpositions then additions.
  • Checks if word is in target word set at start and just returns the word if it is(so you don't need to check it yourself).

Example

npm install micro-spelling-correcter

const MicroSpellingCorrecter = require('micro-spelling-correcter');

let correcter = new MicroSpellingCorrecter(
	[ // list of target words
		'word',
		'sample',
		'hydralisk',
	],
	1 // target maximum distance, defaults to 2
);

correcter.correct('word'); // 'word', fast path
correcter.correct('wurd'); // 'word'
correcter.correct('simple'); // 'sample'
correcter.correct('mutalisk'); // undefined
correcter.correct('ampule'); // undefined
correcter.correct('ampule', 2); // 'sample', with custom edit distance of 2

Keywords

FAQs

Package last updated on 24 Feb 2020

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