Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Named Entity Recognition coherence #2

Closed
jesus-seijas-sp opened this issue Aug 18, 2018 · 1 comment
Closed

Named Entity Recognition coherence #2

jesus-seijas-sp opened this issue Aug 18, 2018 · 1 comment

Comments

@jesus-seijas-sp
Copy link
Contributor

Describe the bug
Named Entity Recognition is not working as expected:

  • If an enumerated entity is added, it only finds the first occurance
  • If there is a regular expression entity that overlaps with an enumerated entity, if returns both instead of finding edges

To Reproduce

const { NlpManager } = require('node-nlp');

const manager = new NlpManager({ languages: ['en'] });
manager.addRegexEntity('mail', /\b(\w[-._\w]*\w@\w[-._\w]*\w\.\w{2,3})\b/ig);
manager.addNamedEntityText('location', 'barcelona', ['en'], ['Barcelona', 'Barna']);
manager.addNamedEntityText('location', 'madrid', ['en'], ['Madrid']);

const result = manager.process('en', 'My mail is barcelona@barcelona.es and i live in madrid', {});
console.log(result);

Expected behavior
Currently it returns:

[ { start: 11,
       end: 20,
       levenshtein: 0,
       accuracy: 1,
       option: 'barcelona',
       sourceText: 'Barcelona',
       entity: 'location',
       utteranceText: 'barcelona' },
     { start: 11,
       end: 33,
       accuracy: 1,
       sourceText: 'barcelona@barcelona.es',
       utteranceText: 'barcelona@barcelona.es',
       entity: 'mail' } ]

It should return:

[ { start: 11,
       end: 33,
       accuracy: 1,
       sourceText: 'barcelona@barcelona.es',
       utteranceText: 'barcelona@barcelona.es',
       entity: 'mail' },
{ start: 48,
       end: 53,
       levenshtein: 0,
       accuracy: 1,
       option: 'madrid',
       sourceText: 'Madrid',
       entity: 'location',
       utteranceText: 'madrid' }
   ]
@jesus-seijas-sp
Copy link
Contributor Author

Solved by two strategies:

  1. Refactored Named Entities and Manager so find several occurences per utterance
  2. Implemented a reduce edges strategy: https://github.com/axa-group/nlp.js/blob/master/lib/util/similar-search.js#L242

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant