nlp.js icon indicating copy to clipboard operation
nlp.js copied to clipboard

Limiting which entities are parsed with NER based on intent

Open danbulant opened this issue 3 years ago • 3 comments

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.

danbulant avatar Aug 11 '21 17:08 danbulant

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.

danbulant avatar Aug 12 '21 09:08 danbulant

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 ...

Apollon77 avatar Aug 08 '22 16:08 Apollon77

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.

Apollon77 avatar Aug 12 '22 07:08 Apollon77

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.

ericzon avatar Nov 27 '22 14:11 ericzon

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

Apollon77 avatar Nov 27 '22 19:11 Apollon77

thanks for effort @Apollon77 take your time

ericzon avatar Nov 27 '22 19:11 ericzon

should be addressed by #1221

Apollon77 avatar Nov 30 '22 07:11 Apollon77