nlp

nlp / SpellingCorrection / 0.1.1

README.md

0. TL;DR

This algorithm basically is autocorrection.

1. Introduction

Identify and correct spelling mistakes in given string. Spelling Correction uses a statistical model to find the original word, and returns a confidence value for each of them.

Input:

  • (Required):  A string word*

Output:

  • Corrected words with confidence values

2. Words

*A string word: An English word. (key = word)

{
  "word": "lke"
}

or

"lke"

3. Output

Corrected words with confidence values: Returns possibly several corrected words for a confidence value for each of them.

Example of Corrected Words:

[
  {
    "word": "like",
    "confidence": 0.8430913348946136
  },
  {
    "word": "lie",
    "confidence": 0.06947697111631537
  },
  {
    "word": "le",
    "confidence": 0.0429352068696331
  },
  {
    "word": "lee",
    "confidence": 0.02107728337236534
  },
  {
    "word": "lake",
    "confidence": 0.02107728337236534
  },
  {
    "word": "ke",
    "confidence": 0.00156128024980484
  },
  {
    "word": "luke",
    "confidence": 0.00078064012490242
  }
]

4. Example

Example 1:

  • Parameter 1: A string word.
{
  "word": "bananna"
}

Output:

[
  {
    "word": "banana",
    "confidence": 1.0
  }
]

Example 2:

  • Parameter 1: A string word.
{
  "word": "cannt"
}

Output:

[
  {
    "word": "cannot",
    "confidence": 0.9964028776978417
  },
  {
    "word": "canst",
    "confidence": 0.0035971223021582736
  }
]

5. Credits

For more information, please refer to http://norvig.com/spell-correct.html or http://www.clips.ua.ac.be/pages/pattern-en.