nlp.js
nlp.js copied to clipboard
Limiting which entities are parsed with NER based on intent
Is there a way to limit entities parsed by NER based on the selected intent?
When I have different entities (usually trim entities), it seems they all get checked regardless of the actual intent, even though most of the time they're irrelevant (and it just slows down nlp).
I always have the entities I want mentioned in the document (like %entity%
), and when i add console log to NER getEntitiesFromUtterance
I see they're being picked up correctly. Now I'd like NER to only parse related entities - or not parse them at all (I'm using NlpManager from node-nlp
, not the new v4 syntax as I couldn't find enough docs for it), and let me somehow select which entities to try and parse.
Addition: it seems that NER adds the entities (in their definiton forms, like %entity%
) back into utterancies - even if they're empty.
I have for example profile
, %user% profile
and profile of %user%
. This will define 2 entities - one that's defined as before profile
and one that's defined as after of
. Now if I process profile of
, it will match None
and set optionalUtterance in the result to %user%profile of%user
, which confuses NLU to return None
(even though by itself it nearly identically matches the 3rd document). Now I have far more entities than just that, and when I tried doing basically the same (entities names are changed before I add them to NLP to shorten their names) the optionalUtterance resulted in this: %e43%profile %e44%%e32%%e37%%e42%%e45%%e46%%e47%%e48%%e50%
for input profile of user
, and the intent was set to None
. If I could parse entites only when the intent matches, it would likely solve this issue as I'd have just one entity there instead of 10.
I also stumbled over the fact that a trim entity is also returned if empty. So the question is ... should it be that way?
In my eyes not because an empty string is not a match ...
I prepare a PR for it - also in connection to https://github.com/axa-group/nlp.js/issues/1174 ... but most likely PR nreeds to wait until my other 4 PRs are merged ... It starts to overlap code-wise, so else it gets a merge hell.
Moving forward several topics. We added feedback to all the active PRs to be merged as soon as possible. We'll release a version after that.
Thank you, I saw that ... I will see that I find time the next days to get my brain into the topics again (it is several months ago as I made the PRs and paused all efforts after that to make sure to know how to comntinue - so I do not remember all the "why's" for the changes and such). And some things (e.g. srcAnswer) I need to reevaluate also because of the new infos you provided) Will try my best to provide adjustments
thanks for effort @Apollon77 take your time
should be addressed by #1221