Hi everyone.
I need to migrate a spellchecker component from RASA 2 to RASA 3. I found the RASA 1 version here I have implemented the RASA 2 version below.
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"
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):
global temp, textdata
"""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"""
for k,v in message.data.items():
if k == 'text':
textdata=v
break
#textdata = message.data['text']
temp = textdata.split().copy()
#print('*** one time')
new_message = ' '.join(spell.correction(w) for w in temp)
#print('###### new_msg', new_message)
#print('###### textdata', temp)
message.data['text']=new_message
def persist(self,file_name, model_dir):
"""Pass because a pre-trained model is already persisted"""
pass
I have read the migration guide to RASA 3, but unable to figure it out the changes that I need to make in order for this to work. Can anybody help me in this respect?