Note that there are some explanatory texts on larger screens.

plurals
  1. POSpell Checker for Python
    primarykey
    data
    text
    <p>I'm fairly new with Python and NLTK. I am busy with an application that can perform spell checks(replaces the incorrectly spelled word with the correctly spelled word), Im currently using the Enchant Library on Python-2.7, PyEnchant and the NLTK library. The code below is the class that handles the correction/replacement. </p> <pre><code>from nltk.metrics import edit_distance class SpellingReplacer(object): def __init__(self, dict_name = 'en_GB', max_dist = 2): self.spell_dict = enchant.Dict(dict_name) self.max_dist = 2 def replace(self, word): if self.spell_dict.check(word): return word suggestions = self.spell_dict.suggest(word) if suggestions and edit_distance(word, suggestions[0]) &lt;= self.max_dist: return suggestions[0] else: return word </code></pre> <p>I have written a function that takes in a list of words and performs the def replace on each word and return a list of the words but spelled correctly.</p> <pre><code>def spell_check(word_list): checked_list = [] for item in word_list: replacer = SpellingReplacer() r = replacer.replace(item) checked_list.append(r) return checked_list &gt;&gt;&gt; word_list = ['car', 'colour'] &gt;&gt;&gt; spell_check(words) ['car', 'color'] </code></pre> <p>Now I don't really like this because it isn't very accurate and I'm looking for a way to achieve spelling checks and replacements on words. I also need something that can pick up spelling mistakes like "caaaar"? Are there better ways to perform spelling checks out there? If so what are they? How does Google do it for example because their spelling suggester is very good? Any suggestions </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload