npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fuzzy-spell-correction

v0.0.5

Published

fuzzy spell correction library based on redis database and Dice's coefficient

Downloads

10

Readme

fuzzy spell correction library based on redis database and Dice's coefficient

fuzzy-spell-correction

you need to install redis database first

usage

start redis

$redis-server

create fill.js

var	corrector = require ('fuzzy-spell-correction'),
		redis = require ('redis'),
		db = redis.createClient ();

corrector.db = db;

corrector.add ('we where promised jetpacks™');

create usage.js

var	corrector = require ('fuzzy-spell-correction'),
		redis = require ('redis'),
		db = redis.createClient ();
		
corrector.db = db;

corrector ('we were promized jetpaks', function (err, phrase) {
	console.log (phrase); // -> ['we where promised jetpacks™']
});

you cannot run code in fill.js and usage.js at the same time, because corrector.add is async operation, and at point in time when you try to correct misspelled word, the right spelled word may be not in a dictionary

i might add support for callback to corrector.add operation, but in real-world cases it isn't necessary

methods

adding words to a dictionary

corrector.add ('word1', 'word2');
corrector.add (['word3', 'word4']);

trying to correct

corrector ('mispelled', function (err, result) {
	console.log (result); // -> ['right spelled'];
});
corrector (['mispelled', 'mispelled2'], function (err, result) {
	console.log (result); // -> ['right spelled1', 'right spelled2'];
});

###some statistics###

array of all possible letters in words (useful in quick-checking existance of a word)

corrector.getLetters (function (err, letters) {
	// same as client.smembers ('_LETTERS_');
	console.log (letters) // -> ['w','e','r','p','r','o','m','i','s','d','j','t','p','a','k','s','w','1', '2','3','4'];
});

maximum length of a word in dictionary

corrector.getMaxLength (function (err, maxLength) {
	// same as client.get ('_MIN_LENGTH_');
	console.log (maxLength) // -> 24
});

minimum length of a word in a dictionary

corrector.getMinLength (function (err, minLength) {
	// same as client.get ('_MAX_LENGTH_');
	console.log (minLength) // -> 4
});

advanced

algorithm leverages n-grams and Dice's coefficient, whatever does it means

you can change some parameters by setting corrector.n = Number|0 and corrector.ranking = function (word1, word2) {return Number|0}

n is for n-grams (trigrams by default)

ranking is for words metric distance (dice coefficient by default)