We are trying to write a custom component for our pipeline, but can’t seem to get it to work. This is what we currently have:
from rasa.nlu.components import Component
class PreProcessing(Component):
"""A custom sentiment analysis component"""
name = "preprocessing"
provides = []
requires = []
defaults = {}
language_list = []
def __init__(self, component_config=None):
super(PreProcessing, self).__init__(component_config)
def process(self, message, **kwargs):
"""Retrieve the tokens of the new message, pass it to the classifier
and append prediction results to the message class."""
return message.lower() # here, process text somehow. For example lowercase on input
and the config.yml
file looks like:
language: "../../language_models/nb_core_news_lg"
recipe: default.v1
# Read the following docs on how to fine-tune a model using config.
# https://rasa.com/docs/rasa/tuning-your-model#component-lifecycle
pipeline:
- name: "preprocessing.PreProcessing"
## Required pipeline components ##
- name: SpacyNLP
# note: this path is relative to ./live-bots/bot_name, where it's imported.
model: "../../language_models/nb_core_news_lg"
case_sensitive: False
...
This however does not seem to be working. The preprocessing of the text is not being picked up by the component SpacyNLP. Our custom component does not need to be trained, but the input text just needs to be processed. Any tips?