Hi everyone!! <3
Build a custom component for spell checking
i want to spell checking for language Vietnammese.
For example: “Xin chao Rasa!”
Output of the code will look like this: “Xin chào Rasa!” code:
from rasa.nlu.components import Component
from rasa.nlu import utils
from rasa.nlu.model import Metadata
from pyvi import ViUtils
# from spellchecker import SpellChecker
# spell = SpellChecker()
class CorrectSpelling(Component):
name = "Spell_checker"
provides = ["message"]
requires = ["message"]
language_list = ["en"]
def __init__(self, component_config=None):
super(CorrectSpelling, self).__init__(component_config)
def train(self, training_data, cfg, **kwargs):
"""Not needed, because the the model is pretrained"""
pass
def process(self, message, **kwargs):
"""Retrieve the text message, do spelling correction word by word,
then append all the words and form the sentence,
pass it to next component of pipeline"""
textdata = message.text
new_message = ViUtils.add_accents(textdata)
message.text = new_message
def persist(self,file_name, model_dir):
"""Pass because a pre-trained model is already persisted"""
pass
file python name spellchecking.py i add it to C:\Users\ADMIN\anaconda3\Lib\site-packages\rasa_nlu register it in rasa_nlu/registry.py"
from rasa_nlu.spellchecking import CorrectSpelling
and
component_classes = [
CorrectSpelling,
SpacyNLP, MitieNLP,
SpacyEntityExtractor, MitieEntityExtractor, DucklingExtractor,
CRFEntityExtractor, DucklingHTTPExtractor,
EntitySynonymMapper,
SpacyFeaturizer, MitieFeaturizer, NGramFeaturizer, RegexFeaturizer,
MitieTokenizer, SpacyTokenizer, WhitespaceTokenizer,
SklearnIntentClassifier, MitieIntentClassifier, KeywordIntentClassifier,
]
i run rasa train, and i get it:
(base) D:\AI Project\GroooBot>rasa train
fatal: bad revision 'HEAD'
InvalidConfigException: Can't load class for name 'CorrectSpelling'. Please make sure to provide a valid name or module path and to register it using the '@DefaultV1Recipe.register' decorator.
Please help me fix it. Thanks very much!!!