spellchecker module

spellchecker.P(word, N=28526)[source]

Probability of word

Parameters:
  • word (string) – kata
  • N (integer) – jumlah n kata, defaults to sum(WORDS.values())
Returns:

Probability of word

Return type:

float

spellchecker.candidates(word)[source]

Generate possible spelling corrections for word

Parameters:word (string) – kata
Returns:set of candidates words
Return type:set
spellchecker.correction(word)[source]

Most probable spelling correction for word flow: word –> edits1(word) –> edits2(word) –> known(words) –> candidates(word) –> correction(word) with P as key

Parameters:word (string) – kata
Returns:word within maximum Probability
Return type:string
spellchecker.edits1(word)[source]

All edits that are one edit away from word

Parameters:word (string) – kata
Returns:all kinds edit that are one edit away from word
Return type:set
spellchecker.edits2(word)[source]

All edits that are two edits away from word

Parameters:word (string) – kata
Returns:all kinds edit that are twice edit away from word
Return type:set
spellchecker.known(words)[source]

The subset of words that appear in the dictionary of WORDS

Parameters:words (list) – list of word
Returns:set of words that appear in the dictionary of WORDS
Return type:set