axa-group / nlp.js

An NLP library for building bots, with entity extraction, sentiment analysis, automatic language identify, and so more

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NerManager is not a constructor

jamesst78 opened this issue · 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?

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

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

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

commented

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

@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?

commented

@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

commented

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 spiderman@gmial.com',
    'en',
  ).then(entities => console.log(entities));

but findEntities is from v3 and aint working.

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

commented

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.

commented

@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?

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

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")