Hello!
I am trying to create a custom component, which overwrite the user input message. I am working on rasa version 2.3.4. I have read the documentation, the forum discussions, and have considered the different suggestions, but I can’t get it to work!
Your input → Hee llo!!! my name is: DÁÑIEL, 35=YEARS old! someone on the other side?? rasa.core.processor - Received user message ‘Hee llo!!! my name is: DÁÑIEL, 35=YEARS old! someone on the other side??’
My custom component not overwrite the user input message.
my config.yml looks like this:
language: es
pipeline:
- name: edit_message.Preprocessor
- name: SpacyNLP
- model: es_core_news_sm
and my custom component: import typing
from typing import Any, Optional, Text, Dict, List, Type
import re
import unidecode
from rasa.nlu.components import Component
from rasa.nlu.config import RasaNLUModelConfig
from rasa.shared.nlu.training_data.training_data import TrainingData
from rasa.shared.nlu.training_data.message import Message
if typing.TYPE_CHECKING:
from rasa.nlu.model import Metadata
class edit_message(Component):
provides = ["text"]
#requires = []
defaults = {}
language_list = None
def __init__(self, component_config=None):
super(edit_message, self).__init__(component_config)
def train(self, training_data, cfg, **kwargs):
pass
def process(self, message: Message, **kwargs: Any) -> None:
mt = message.get("text")
if mt!=None:
mt = unidecode.unidecode(mt)
mt = mt.lower()
mt = re.sub(r'(\!)', " ! ", mt)
mt = re.sub(r'(\:)', " : ", mt)
mt = re.sub('=', ' = ', mt)
mt = re.sub(r'(\?)', " ? ", mt)
mt = re.sub(r'\s{2,}', ' ', mt)
message.set('text', mt, add_to_output = True)
pass
Can anybody help me?