Using Regex with Rasa
Asked Answered
J

1

6

I'm trying to use Rasa to detect entities such as phone numbers or contract ID. It seems natural to use regular expressions to define precisely those entities, and Rasa does have something called "Regular Expression Features" which allows us to define regular expressions.

Except I don't understand how to use them. In the Rasa-NLU tutorial, there are regexes (like "zipcode"), but I don't see how they are linked to entities ("location").

Does anyone have a clue about how regexes work with Rasa ?

Jude answered 30/3, 2018 at 13:59 Comment(3)
How can you define a location with a regex? See this explanation on what regexes are for in Rasa-NLU. You provide a name for the entity, set the pattern, and the ner_crf component will be able to use this information to improve results.Loiret
@WiktorStribiżew I linked this page in my question. It is specified that "The name doesn’t define the entity nor the intent, it is just a human readable description for you to remember what this regex is used for.", so the name is meaningless for Rasa. And the regex does not define a location, but a zipcode, and the example takes zipcodes as values for the location entity.Jude
Add all relevant details to the question.Loiret
I
11

The regexes you define are not linked to any entity or intent explicitly. What a regex does is add a new feature to your input, e.g. an extra vector element which can be 1 or 0 depending on whether the regex matched. When you train, the model now has this extra information about each of your examples, and can choose itself when to pay attention to it.

Insuppressible answered 31/3, 2018 at 12:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.