axa-group / nlp.js

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

NerManager is not a contructor in 4+ #360

Closed NeuronButter closed 1 year ago

NeuronButter commented 4 years ago

Well, not only that, but a clean installation of node-nlp doesn't have this:

const nlp = require('node-nlp')
nlp.NerManager // Doesn't exist at all

Steps to reproduce the behavior:

  1. Install the latest version of NLP.js from NPM
  2. Try to see if nlp.NerManager exists in the first place.

Expected behavior I expect NerManager at the very least to exist.

Screenshots: image And as you can see in this screenshot, a lot of other features are missing from a fresh install. image

So umm yeah, NerManager isn't a thing apparently?

EDIT: This seems to only be an issue with the latest version that NPM is serving (could be the latest latest, or v4.0.0-rc.*), but 3.10.2 (latest 3 build) works.

jesus-seijas-sp commented 4 years ago

Hello: NerManager is a thing, but know in version 4.x it's a thing by itself. More on that, there is a big work in the version 4 to make the NER able to extract from millions of rules in milliseconds, while in the version 3 it was minutes to make the same: https://github.com/axa-group/nlp.js/issues/337

Version 3.x was monolthic: it was 1 package with all, and not modular so "you use it at it is". Version 4.x is no longer monolithic: is a lot of packages each one with one function, so you can use the packages separately without installing "the whole bunch". This is a big improvement not only because allows you to replace different pieces from the equation (example, you can replace the NLU only for a language and use LUIS instead, or in another language use Watson,....), but also if you use it in web or mobile the size of the package has been reduced from 3MB down to 200KB, because you only includes what you need instead of all (if you are building a bot in english you don't need all the other 33 languages...).

You can see here all the packages that exists: https://github.com/axa-group/nlp.js/tree/master/packages

One of the packages is called "ner", it contains a class Ner that represents the previous NerManager. Other concept in the version 4 is the container: you have a container to register instances and classes, so if you want to use a different Ner you only have to register your own as a plugin.

The problem with version 4 is that is still release candidate, and we need a hard work to document it all, as it is huge compared with version 3.

So you have 3 options:

  1. Use the version 3.
  2. If you want to use only the ner, use the module @nlpjs/ner. It includes unit tests to describe how it works.
  3. If you want to use the full NLP but access its ner instance, then work with version 4, and access it from the container like this:
const { NlpManager } = require('node-nlp');

async function main() {
  const manager = new NlpManager({ languages: ['en'] });
  const nerManager = manager.container.get('ner');
  console.log(nerManager);
}

main();
NeuronButter commented 4 years ago

Alright, thanks for that. Before closing off this issue though, for each respective branch (3 for 3, 4 for master), could we get updated docs? Thanks!

Caperious commented 4 years ago

Any updates on the docs?

Apollon77 commented 2 years ago

I did a part in #1171

aigloss commented 1 year ago

Closing due to inactivity. Please, re-open if you think the topic is still alive.