Custom component getting previous components POS tags and entity classification

Hi,

Wasn’t sure how to phrase this question, but I’m currently trying to implement a custom component to try and extract entities that fail to get picked up by CRFEntityExtractor. I’ve currently gotten a basic structure setup for the new component based off of the tutorial, but I’d liked to get the classifications from Spacy as well as CRFEntityExtractor. Is this part of the message object passed into the process function?

I’m currently trying to print out the message and tokens with:

logging.info("Message passed in: {message}".format(message=message))
tokens = [t.text for t in message.get("tokens")]
logging.info("tokens: {tokens}".format(tokens=tokens))

I’m only getting back:

2019-08-09 15:10:16 INFO     root  - Message passed in: <rasa.nlu.training_data.message.Message object at 0x00000181A52BC128>
2019-08-09 15:10:16 INFO     root  - tokens: ['hi']

Is it possible to get POS tags or whether or not an entity was identified? I’ve added my component at the very bottom of the Spacy pipeline.

Thanks

If your component comes after the all other components, the spacy doc and the entities should be included in the message object. Did you try to access them via message.get("entities") and message.get("spacy_doc")?

When printing the message you should use message.as_dict().

Hi Tanja,

No I wasn’t aware of how to use the message object. Is there more documentation on what is accessible? I will try what you have suggested.

Thanks!

@sihsob No, unfortunately we don’t have documentation on that. You have to look into the code itself to get more information about the message object. Let me know if you need more information.