Skip to content

Instantly share code, notes, and snippets.

@nikhilcheke
nikhilcheke / spellchecking.py
Last active October 8, 2020 12:16
Custom component for spell checking in Rasa NLU
from rasa.nlu.components import Component
from rasa.nlu import utils
from rasa.nlu.model import Metadata
from spellchecker import SpellChecker
spell = SpellChecker()
class CorrectSpelling(Component):
name = "Spell_checker"
@nikhilcheke
nikhilcheke / spellcorrector.py
Created October 8, 2020 08:35
Sample spell corrector using pyspellchecker
from spellchecker import SpellChecker
spell = SpellChecker()
# find those words that may be misspelled
misspelled = spell.unknown(['this', 'is', 'pythen', 'code'])
for word in misspelled:
print("Misspelled word: "+word+"\nCorrected word: "+spell.correction(word))