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

NerManager is not a constructor

Open jamesst78 opened this issue 3 years ago • 3 comments

Hello, I'm currently using the code in the NER documentation page

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

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

I get an error from node that NerManager is not a constructor. I can't even find the named import of NerManager in the node-nlp package. Can I please get some help?

jamesst78 avatar Aug 28 '22 16:08 jamesst78

Yes, the nre manager is currently not exported on the main module. What you want to do?

Apollon77 avatar Aug 28 '22 19:08 Apollon77

I'd like to setup some NER enums like the documentation page supplied here with the spiderman example https://github.com/axa-group/nlp.js/blob/master/docs/v3/ner-manager.md

jamesst78 avatar Aug 29 '22 18:08 jamesst78

Yes ... this is the v3 documentation :-)) I started providing v4 docs in one of my PRs ... maybe try like https://github.com/axa-group/nlp.js/pull/1171/files#diff-6e3a555ca9a8cfee3e84d492bc5db05702d7d2a6508afc7098a6ce9c60cf46da ... not reviewed so far, but working for me

Apollon77 avatar Aug 29 '22 18:08 Apollon77

@Apollon77 the documentations is weak compared to v3. No full examples. No idea how to findEntities after setting up rules.

trsh avatar Nov 11 '22 08:11 trsh

@trsh Yes you are right ... In my PRs there is some more (doid you had a look?) but also this is hanging around now for months. In fact experiment and if you understood it then send in a PR to add documetation :-)

To your exact question: What exactly you want to do?

Apollon77 avatar Nov 11 '22 08:11 Apollon77

@trsh Yes you are right ... In my PRs there is some more (doid you had a look?) but also this is hanging around now for months. In fact experiment and if you understood it then send in a PR to add documetation :-)

To your exact question: What exactly you want to do?

Set rules and get entities, just like in v3

trsh avatar Nov 11 '22 08:11 trsh

So far

const { dockStart } = require('@nlpjs/basic');

(async () => {
  const dock = await dockStart({ use: ['Basic'] });
  const manager = dock.get('nlp');
  manager.addNerRegexRule('en', 'ownEmail', '/\\b(\\w[-._\\w]*\\w@\\w[-._\\w]*\\w\\.\\w{2,3})\\b/gi');
  manager.findEntities(
    'I saw spiderman eating speghetti in the city and his mail is [email protected]',
    'en',
  ).then(entities => console.log(entities));

but findEntities is from v3 and aint working.

trsh avatar Nov 11 '22 08:11 trsh

it shoudl be extractEntities(locale, utterance, context, settings)

Apollon77 avatar Nov 11 '22 08:11 Apollon77

Looks like renamed to extractEntities. However the fact, that this repo maintainers do not care about updating documentation for months, makes me reach for alternatives. This will be blocker 1, then will fallow 2 and so on, ending up digging into the source code of the library.

trsh avatar Nov 11 '22 08:11 trsh

On one hand: "that this repo maintainers" is a bit "too short tought" ... you know ... open source projects ... community ... working together ;-) But you are right that there should be still time to check community contributions. I already send them an email

On other hand: If you find a maintained one in the JavaScript/Node.js language with a comparable featureset please tell me ... I was not able to find any

Apollon77 avatar Nov 11 '22 08:11 Apollon77

@Apollon77 one more question. If I provide the rules in json, like

{
    ...,
    "entities": {
        "ownEmail": "/\\b(\\w[-._\\w]*\\w@\\w[-._\\w]*\\w\\.\\w{2,3})\\b/gi"
    },
    ...
}

how do I feed it to the manager?

trsh avatar Nov 11 '22 08:11 trsh

For complete usage use corpus jsons like https://github.com/axa-group/nlp.js/pull/1171/files#diff-eba11f3b2ea9073c83d911e970dd4c2d15d211fad3de2afee47d05e02a3c7f60R15

To just bring in entities then it could work using addEntities(entities, locale) (entities must be the JSON-parsed content of "entities")

Apollon77 avatar Nov 11 '22 08:11 Apollon77