Code Monkey home page Code Monkey logo

spell-checker.js's Introduction

Spell-checker.js

Simple expandable tool for spell checking

npm Travis branch

Readme: English Русский

Supported languages

  • English
  • Russian

Quickstart

Install:
npm i spell-checker

Code

const spell = require('spell-checker-js')

// Load dictionary
spell.load('en')

// Checking text
const check = spell.check('Some text to check, blahblahblah, olololo')

console.log(check)
// -> ['blahblahblah', 'olololo']

Methods & properties

spell.load(dictionary) or spell.load(options) — load dictionary file

Examples:

// ways for load default dictionary:
spell.load('ru')
spell.load({ input: 'ru' })

// load custom dictionary with utf-8:
spell.load('./my_custom_dictionary.txt')

// laod custom dictionary with charset:
spell.load({ input: './my_custom_dictionary.txt', charset: 'windows-1251' })

// Asynchronous load default dictionary:
spell.load({ input: 'en', async: true }).then(len => {
    console.log(len);
    // len — amount of added words to base
    spell.check('something')
})

List of default dictionaries:

  • en — list of English words
  • ru — list of Russian words
  • ru_surnames — list of Russian surnames

You can help by adding other languages or expand existing dictionaries

spell.check(string) — spell checking of text

Returns: array of wrong words
Example:

spell.load('en')

const check = spell.check('Some text to check, blahblahblah, olololo')

console.log(check)
// -> ['blahblahblah', 'olololo']

spell.clear() — clear all loaded dictionaries

Example:

spell.load('en')

spell.clear()
spell.check('something')

// -> ERROR! Dictionaries are not loaded

spell.size — number of words in the dictionary are

Example

spell.load('en')
spell.load('ru')

console.log(spell.size)
// -> 1956898

License

MIT © 2016 Danakt Frost

spell-checker.js's People

Contributors

danakt avatar laurent-d avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.