rmiiitb
(rahul)
June 19, 2019, 3:15pm
1
Hello guys,
I’m working on capturing the ‘names’ of the persons. I wrote almost 50+ different ways/names in nlu.md file for training, wrote a regex as well but still if I give a new name the nlu engine is not able to recognise it.
This is how my nlu.md file looks -
regex:name
intent:get_name
I’m using rasa 1.0.7 and I have
pipeline: ‘pretrained_embeddings_spacy’
Could someone please guide me as to what must I do to fix this.
Thanks in advance
Not sure, but have you tried not using Regex? It might be featurizing other words that are not names.
Also, I think that the regex is wrong here. It matches all the characters, followed by a space, at the end of the sentence. Without $
, it matches the entire sentence. With $
, it matches nothing unless you have a space at the end of input.
rmiiitb
(rahul)
June 19, 2019, 4:24pm
3
Thanks for your reply Akshay2000
I started without regex but to no avail. As you mentioned, I will fix the regex now and test it.
rmiiitb
(rahul)
June 19, 2019, 5:23pm
4
Nope, still doesn’t work. The moment I provide a new name, the entity (name) doesn’t get fill.
As @akshay2000 mentioned, regex is not a good idea for names. Have you tried using custom crf and spacy’s built in recognizer?
Also, you could look at lookup tables, they work the best for names.
hey @rmiiitb as suggested by @srikar_1996 you can use CRF entity extractor since you are using custom entities, you can read about it here:
rmiiitb
(rahul)
June 20, 2019, 4:35am
7
Thanks srikar, JG !
Really appreciate the pointers, will work on them.
rmiiitb
(rahul)
June 20, 2019, 5:17am
8
Hey guys,
I did this -
regex:name
^[a-zA-Z]+(([’,. -][a-zA-Z ])?[a-zA-Z]*)$
pipeline:
name: “SpacyNLP”
name: “SpacyTokenizer”
name: “SpacyFeaturizer”
name: “SklearnIntentClassifier”
name: “EntitySynonymMapper”
name: “RegexFeaturizer”
name: “CRFEntityExtractor”
features: [
[“low”, “title”, “upper”],
[“bias”, “low”, “prefix5”, “prefix2”, “suffix5”, “suffix3”,
“suffix2”, “upper”, “title”, “digit”, “pattern”],
[“low”, “title”, “upper”]
]
While running, I gave name as : sasha petrov and got below debug statements -
2019-06-20 10:34:25 DEBUG rasa_sdk.forms - Validating user input
‘{‘intent’:
{‘name’: ‘get_name’, ‘confidence’: 0.9944517383711481},
‘entities’: [],
‘intent_ranking’: [
{‘name’: ‘get_name’, ‘confidence’: 0.9944517383711481},
{‘name’: ‘affirm’, ‘confidence’: 0.0008237922520789642},
.
.
{‘name’: ‘finance_module’, ‘confidence’: 0.00017543870013493048}],
‘text’: ‘sasha petrov’}’
2019-06-20 10:34:25 DEBUG rasa_sdk.forms - Trying to extract requested slot ‘name’ …
2019-06-20 10:34:25 DEBUG rasa_sdk.forms - Got mapping ‘{‘type’: ‘from_entity’, ‘entity’: ‘name’, ‘intent’: [‘get_name’], ‘not_intent’: []}’
2019-06-20 10:34:25 DEBUG rasa_sdk.forms - Failed to extract requested slot ‘name’
2019-06-20 10:34:25 ERROR rasa_sdk.endpoint - Failed to extract slot name with action initial_info_form
rmiiitb
(rahul)
June 20, 2019, 5:18am
9
I will now try without regex.
dcsan
(Dc)
February 28, 2020, 10:22am
10
@rmiiitb did you get anywhere with this? I’m having a similar problem
perhaps the regex recognizer needs to be configured?
I think that you need to add more example in the NLU in order to train it. The confidences in intents aren’t really good on some examples…
For the entity name extraction you maybe can use SpacyEntityExtractor. There is a PERSON entity in it, it may help you
It seems you would need to add it to your pipeline config.yml
Sharada201
(Sharada Pawar)
April 13, 2020, 3:19pm
11
Hi Rahul,
If you want to extract the name of person then you simply use spacy entity extractor.
For that you need to install spacy.
add following in your config file
name: “SpacyNLP”
name: “SpacyEntityExtractor”
dimensions: [“PERSON”,“LOC”,“ORG”,“PRODUCT”]
while slot mapping use entity as a person
self.from_entity(entity=“PERSON”),
1 Like