axa-group / nlp.js

An NLP library for building bots, with entity extraction, sentiment analysis, automatic language identify, and so more
MIT License
6.26k stars 620 forks source link

Documentation for v4? #411

Open taf2 opened 4 years ago

taf2 commented 4 years ago

Reading through issues was able to figure out to get to NerManager we have to do the following:

const manager = new NlpManager({ languages: JSON.parse(languages), threshold: 0.8 });
const nerManager = manager.container.get('ner');

Instead of

const manager = new NerManager({ threshold: 0.8 });

But now the interface is still different so things like:

nerManager.addNamedEntityText(entity.name, entity.word, [entity.lang], entity.versions);

Are broken but scanning through ner.js it's unclear how this migrates forward in v4 from v3?

Sorry if I'm missing something obvious...

taf2 commented 4 years ago

Okay seems like the solution is to use the NlpManager object directly? Now the question is how do we access the equivalent NerManager#findEntities function?

trying to see if maybe we use:

  //let entities = nerManager.findEntities(params.text, params.lang);
     let entities = nerManager.getEntitiesFromUtterance(params.lang, params.text);

getEntitiesFromUtterance instead of findEntities? but I'm getting 0 results where we used to get at least 1 result... maybe another initialization step missing/required or a different method required...

SaltedBlowfish commented 4 years ago

@taf2 I'm having the same issue extracting entities. Did you ever solve this?

taf2 commented 4 years ago

@SaltedBlowfish sort of i am using spacy.io