How can I apply the spell checker function to a large data set?

540 Views Asked by At

I have a spell check function( Peter Novig's spell correction) that works on small data frames but for data frames with 5000 words it takes a long time to run and I stop the program. Does anyone have a solution?

#correct spelling
import enchant
from spellchecker import SpellChecker
spell = SpellChecker()
def spell_correct(text):
        try:
            output = ""
            splited_words = text.split()
            d = enchant.Dict("en_US")
            for i in splited_words:
                if d.check(i):
                    output = output + i + " "
                else:
                    output = output + spell.correction(i) + " "
        except Exception as e:
            print(e)
        return output
    
df["Text"] = df["Text"].apply(spell_correct)
df

0

There are 0 best solutions below