Closed aRandomKiwi closed 1 year ago
When two entities come, then the entity is not fullfiled with the first one, it is identified as being a list instead:
But you can use the conditions at answers to detect:
Example of corpus:
{
"name": "Corpus with entities",
"locale": "en-US",
"contextData": "./heros.json",
"data": [
{
"intent": "hero.realname",
"utterances": [
"what is the real name of @hero"
],
"answers": [
{ "answer": "The real name of {{ hero }} is {{ _data[entities.hero.option].realName }}", "opts": "entities.hero !== undefined && !entities.hero.isList" },
{ "answer": "Well, perhaps you can tell me only one hero at a time", "opts": "entities.hero !== undefined && entities.hero.isList" },
{ "answer": "You have to specify a hero", "opts": "entities.hero === undefined" }
]
},
{
"intent": "hero.city",
"utterances": [
"where @hero lives?",
"what's the city of @hero?"
],
"answers": [
{ "answer": "{{ hero }} lives at {{ _data[entities.hero.option].city }}", "opts": "entities.hero !== undefined && !entities.hero.isList" },
{ "answer": "Well, perhaps you can tell me only one hero at a time", "opts": "entities.hero !== undefined && entities.hero.isList" },
{ "answer": "You have to specify a hero", "opts": "entities.hero === undefined" }
]
}
],
"entities": {
"hero": {
"options": {
"spiderman": ["spiderman", "spider-man"],
"ironman": ["ironman", "iron-man"],
"thor": ["thor"]
}
},
"email": "/\\b(\\w[-._\\w]*\\w@\\w[-._\\w]*\\w\\.\\w{2,3})\\b/gi"
}
}
I am seeing the same issue
Hoping for a more convenient builtin solution in latest release.
Maybe "opts": "entities.hero !== undefined && !entities.hero.isList"(and other two ) could be added automatically when trainning or running.
@jesus-seijas-sp I added your example to the new docs I did for v4 slot filling ... see https://github.com/axa-group/nlp.js/pull/1171/files#diff-63e03ba61fe1b78e6dbc539dfb6c81be93d6aff1e19980d9d030fd4162915890
@atubo2012 How you think this could get "more convenient"? You need to define/know what you need when you design the answers ... I think this is nothing that can be generalized
PS: The only question if if we not should just catch the exception and replace nothing in such a case
Closing due to inactivity. Please, re-open if you think the topic is still alive.
Describe the bug When two or more entities are mentioned in a user input, evaluator.js throw an uncatched exception, so there is no output text (easily reproducible with the ner example provided by the NLP.js repository).
To Reproduce Steps to reproduce the behavior:
Expected behavior NLP.js (evaluator.js) process at least one of the mentioned entities and ignore the others instead of crashing (throwing an exception) and answer nothing.
Desktop (please complete the following information):