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

Overview

NLPjs logo

NLP.js

Build Status Coverage Status NPM version NPM downloads Sonarcloud Status Maintainability Rating Reliability Rating Security Rating

If you're looking for the version 3 docs, you can find them here Version 3

"NLP.js" is a general natural language utility for nodejs. Currently supporting:

  • Guess the language of a phrase
  • Fast Levenshtein distance of two strings
  • Search the best substring of a string with less Levenshtein distance to a given pattern.
  • Get stemmers and tokenizers for several languages.
  • Sentiment Analysis for phrases (with negation support).
  • Named Entity Recognition and management, multi-language support, and acceptance of similar strings, so the introduced text does not need to be exact.
  • Natural Language Processing Classifier, to classify an utterance into intents.
  • NLP Manager: a tool able to manage several languages, the Named Entities for each language, the utterances, and intents for the training of the classifier, and for a given utterance return the entity extraction, the intent classification and the sentiment analysis. Also, it is able to maintain a Natural Language Generation Manager for the answers.
  • 40 languages natively supported, 104 languages supported with BERT integration
  • Any other language is supported through tokenization, even fantasy languages

Hybrid bot

New in version 4!

Version 4 is very different from previous versions. Before this version, NLP.js was a monolithic library. The big changes:

  • Now the library is split into small independent packages.
  • So every language has its own package
  • It provides a plugin system, so you can provide your own plugins or replace the existing ones.
  • It provides a container system for the plugins, settings for the plugins and also pipelines
  • A pipeline is code defining how the plugins interact. Usually it is linear: there is an input into the plugin, and this generates the input for the next one. As an example, the preparation of a utterance (the process to convert the utterance to a hashmap of stemmed features) is now a pipeline like this: normalize -> tokenize -> removeStopwords -> stem -> arrToObj
  • There is a simple compiler for the pipelines, but they can also be built using a modified version of javascript and python (compilers are also included as plugins, so other languages can be added as a plugin).
  • NLP.js now includes connectors, a connector is understood to be something that has at least 2 methods: hear and say. Examples of connectors included: Console Connector, Microsoft Bot Framework Connector and a Direct Line Offline Connector (this one allows you to build a web chatbot using the Microsoft Webchat, but without having to deploy anything in Azure).
  • Some plugins can be registered by language, so for different languages different plugins will be used. Also some plugins, like NLU, can be registered not only by language but also by domain (a functional set of intents that can be trained separately)
  • As an example of per-language/domain plugins, a Microsoft LUIS NLU plugin is provided. You can configure your chatbot to use the NLU from NLP.js for some languages/domains, and LUIS for other languages/domains.
  • Having plugins and pipelines makes it possible to write chatbots by only modifying the configuration and the pipelines file, without modifying the code.

TABLE OF CONTENTS

Installation

If you're looking to use NLP.js in your Node application, you can install via NPM like so:

    npm install node-nlp

React Native

There is a version of NLP.js that works in React Native, so you can build chatbots that can be trained and executed on the mobile even without the internet. You can install it via NPM:

    npm install node-nlp-rn

Some limitations:

  • No Chinese
  • The Japanese stemmer is not the complete one
  • No Excel import
  • No loading from a file, or saving to a file, but it can still import from JSON and export to JSON.

Example of use

You can see a great example of use in the folder /examples/02-qna-classic. This example is able to train the bot and save the model to a file, so when the bot is started again, the model is loaded instead of being trained again.

You can start to build your NLP from scratch with a few lines:

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

const manager = new NlpManager({ languages: ['en'], forceNER: true });
// Adds the utterances and intents for the NLP
manager.addDocument('en', 'goodbye for now', 'greetings.bye');
manager.addDocument('en', 'bye bye take care', 'greetings.bye');
manager.addDocument('en', 'okay see you later', 'greetings.bye');
manager.addDocument('en', 'bye for now', 'greetings.bye');
manager.addDocument('en', 'i must go', 'greetings.bye');
manager.addDocument('en', 'hello', 'greetings.hello');
manager.addDocument('en', 'hi', 'greetings.hello');
manager.addDocument('en', 'howdy', 'greetings.hello');

// Train also the NLG
manager.addAnswer('en', 'greetings.bye', 'Till next time');
manager.addAnswer('en', 'greetings.bye', 'see you soon!');
manager.addAnswer('en', 'greetings.hello', 'Hey there!');
manager.addAnswer('en', 'greetings.hello', 'Greetings!');

// Train and save the model.
(async() => {
    await manager.train();
    manager.save();
    const response = await manager.process('en', 'I should go now');
    console.log(response);
})();

This produces the following result in a console:

{ utterance: 'I should go now',
  locale: 'en',
  languageGuessed: false,
  localeIso2: 'en',
  language: 'English',
  domain: 'default',
  classifications:
   [ { label: 'greetings.bye', value: 0.698219120207268 },
     { label: 'None', value: 0.30178087979273216 },
     { label: 'greetings.hello', value: 0 } ],
  intent: 'greetings.bye',
  score: 0.698219120207268,
  entities:
   [ { start: 12,
       end: 14,
       len: 3,
       accuracy: 0.95,
       sourceText: 'now',
       utteranceText: 'now',
       entity: 'datetime',
       resolution: [Object] } ],
  sentiment:
   { score: 1,
     comparative: 0.25,
     vote: 'positive',
     numWords: 4,
     numHits: 2,
     type: 'senticon',
     language: 'en' },
  actions: [],
  srcAnswer: 'Till next time',
  answer: 'Till next time' }

False Positives

By default, the neural network tries to avoid false positives. To achieve that, one of the internal processes is that words never seen by the network are represented as a feature that gives some weight to the None intent. So, if you try the previous example with "I have to go" it will return the None intent because 2 of the 4 words have never been seen while training. If you don't want to avoid those false positives, and you feel more comfortable with classifications into the intents that you declare, then you can disable this behavior by setting the useNoneFeature to false:

const manager = new NlpManager({ languages: ['en'], nlu: { useNoneFeature: false } });

Log Training Progress

You can also add a log progress, so you can trace what is happening during the training. You can log the progress to the console:

const nlpManager = new NlpManager({ languages: ['en'], nlu: { log: true } });

Or you can provide your own log function:

const logfn = (status, time) => console.log(status, time);
const nlpManager = new NlpManager({ languages: ['en'], nlu: { log: logfn } });

Contributing

You can read the guide for how to contribute at Contributing.

Contributors

Contributors

Made with contributors-img.

Code of Conduct

You can read the Code of Conduct at Code of Conduct.

Who is behind it?

This project is developed by AXA Group Operations Spain S.A.

If you need to contact us, you can do it at the email [email protected]

License

Copyright (c) AXA Group Operations Spain S.A.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Comments
  • Performance of findEntities. Any tips to improve?

    Performance of findEntities. Any tips to improve?

    I am using the the NerManager to create named entities and am also using the React Native version of the library.

    For my use case there are 10,000 airports...this is the named entity I am adding...

            this.ner.addNamedEntityText(
                'airport',
                airport.airportId,
                ['en'],
                [airport.name, airport.shortName, getAirportAcronymn(airportCode," "), airportCode, getNatoPhonetic(airportCode)]
              );
    

    I then am passing this content to findEntities...

    What is the elevation of Allegheny County Airport

    It takes 40+ seconds to return the result. It does successfully return that there is an airport entity in the string.

    When I get rid of all of the synonyms it still takes 15 seconds. Without the synonyms though, it wouldn't be that useful because there are multiple ways to say.

    For this use case I am only adding one named entity type, but I assume if I add many more the performance would keep decreasing.

    Any tips?

    opened by jeffbonasso-ambifi 34
  • feat: Optimize slot finding answer processing

    feat: Optimize slot finding answer processing

    Pull Request Template

    PR Checklist

    • [x] I have run npm test locally and all tests are passing.
    • [x] I have added/updated tests for any new behavior.
    • [x] If this is a significant change, an issue has already been created where the problem / solution was discussed: [N/A, or add link to issue here]

    I currently can not intall the project because of issues reported with some used tarballs. WHen I execute the tests eslint reports 16 errors and 47 warnings all over the place. I can try to fix them, but So I decided to not add new tests. Please tell me if needed

    PR Description

    While checking out slot Filling with v4 I encountered several unexpected topics I solve in this PR:

    • When using slot filling there was a "srcAnswer" property added to the result, but this was not processed like the other answers by nlg. The PR adds that
    • the nlg text rendering had an issue that when a contact was set that then "optional answer text" was not processed because done but ignored and original text was used. PR also addresses that
    • The answers were rendered before the slot filling filled relevant entities. This PR adjust the order of actions to allow entities to be rendered correctly
    • When a slot was requested the full uterance was always filled as entity - also if the entity was already parsed by buoltins or such. This lead to duplicated entries. This PR changes it so that the fallback "full utterance" is only added as entity if not filled already
    • If a context contains a earlier srcAnswer property then this was repeated also if all mandatory entities were filled in the meantime. This PR removes the srcAnswer if all mandatory entities are filled.
    • If slot filling is used the nlp code adds a special "entity utterance", but uses the initial locale parameter (whcih could be empty) to create this. This pot. leads to an empty locale used and then ner only uses the default builtins and not the configured builtins (e.g, Duckling). This PR uses a potentially already determinded locale.
    • When slot filling generated an answer this was provided in srcAnwer additionally to pot. a normal "answer". DirectLineConnector as example is not sending back srcAnswer, so the question is not sent out. This PR changes the behaviour so that when the srcAnswer property is set this is also used as "answer", because it is "the better answer" :-)
    • Actions are executed after the answers are rendered. With this actions can not modify the context to e.g. inkject new entities to be used in answer rendering. This PR adds a new nlp setting "executeActionsBeforeAnswers" to allow to execute the actions before answer rendering.
    • Fix handling of numbered entities in slot filling and answer generation (added it here because else would have conflicted with PR #1164)

    In fact it is a feature addition for handing slot filling answers by processing them like the other answers.

    addresses #410, addresses #454, addresses #934, fixes #582, fixes #307

    Additonally the commits are not "convenionally named". Sorry for that. Saw that too late and will change in future commits

    opened by Apollon77 20
  • Big Amount of data big delay train

    Big Amount of data big delay train

    Describe the bug 4 days pass to train 415703 inputs ?? and its not done yet..

    To Reproduce Steps to reproduce the behavior: image

    Expected behavior It took 35 hours just to load all data

    **Desktop **

    • OS: Windows 10
    • Browser Node JS 10.15
    • Version latest

    PC info : CPU : Core i7 4770 @3.40 GHz Ram : 16 GB GPU : GTX 750

    image

    image

    Its normal for that amont of data ???

    opened by ran-j 17
  • Cannot destructure property 'intent' of 'input.classifications[0]' as it is undefined.

    Cannot destructure property 'intent' of 'input.classifications[0]' as it is undefined.

    Sometimes getting an error message when running NlpManager.process (version 4.14.2)

    UnhandledPromiseRejectionWarning: TypeError: Cannot destructure property 'intent' of 'input.classifications[0]' as it is undefined.
    

    at @nlpjs/nlu/src/nlu-neural.js:41:13

    input.classifications will in these scenarios be an empty array, which causes the following line to fail: const { intent } = input.classifications[0];

    Here's what i'm doing in code, don't think there's anything very special here:

      const nlpManager = new NlpManager({ languages: ['sv'], nlu: { log: false } });
      for (const {text, expected_classification} of inputs1) {
        nlpManager.addDocument('sv', text, expected_classification);
      }
      await nlpManager.train();
      for (const { text } of inputs2) {
          const classifications = await nlpManager.process(text); // throws error for some inputs
         // check classification
      }
    
    opened by Dadibom 16
  • build(deps): bump mongodb from 3.6.5 to 4.1.0

    build(deps): bump mongodb from 3.6.5 to 4.1.0

    Bumps mongodb from 3.6.5 to 4.1.0.

    Release notes

    Sourced from mongodb's releases.

    v4.1.0

    The MongoDB Node.js team is pleased to announce version 4.1.0 of the mongodb package!

    Release Highlights

    This release includes load balancer support, intended for use with the beta Serverless platform. When using the driver with Serverless, the SRV URI will automatically put the driver into this mode. When wanting to use a non-SRV URI one must add the loadBalanced=true option to the URI to put the driver into this mode. Being in this mode enables the driver to properly route transactions and cursors to the correct service behind the load balancer.

    The release also fixes an important bug where the original release of the v4 driver enabled command monitoring by default, which caused many reported observations of performance degradation when upgrading from v3 of the driver. Command monitoring is now once again disabled by default and must be enabled by passing in { monitorCommands: true } to the client if desired.

    Features

    • NODE-2843: implement sessions advanceClusterTime method (#2920) (1fd0244)
    • NODE-3011: Load Balancer Support (#2909) (c554a7a)

    Bug Fixes

    • NODE-2883: Aggregate Operation should not require parent parameter (#2918) (dc6e2d6)
    • NODE-3058: accept null or undefined anywhere we permit nullish values (#2921) (b42a1b4)
    • NODE-3441: fix typings for createIndexes (#2915) (f87f376)
    • NODE-3442: AsyncIterator has incorrect return type (#2916) (4a10389)
    • NODE-3452: readonly filters not permitted by typings (#2927) (ce51e78)
    • NODE-3510: omit incorrect | void in declaration of Promise overload of rename() (#2922) (58c1e84)
    • NODE-3513: default command monitoring to off (#2926) (3c60245)

    Documentation

    We invite you to try the mongodb library immediately, and report any issues to the NODE project.

    v4.0.1

    The MongoDB Node.js team is pleased to announce version 4.0.1 of the mongodb package!

    Release Highlights

    This release fixes two small but important bugs from our 4.0.0 release:

    • Webpack will no longer throw an error when trying to bundle the driver
    • Snapshot sessions will now correctly apply the snapshot time when initiated with a distinct operation

    We hope this improves your upgrade experience!

    Bug Fixes

    • NODE-3199: unable to bundle driver due to uncaught require (#2904) (9e48bbd)
    • NODE-3393: snapshot time not applied if distinct executed first (#2908) (7aa3008)
    • NODE-3417: allow calling db() before MongoClient is connected (#2889) (51ea86d)

    ... (truncated)

    Changelog

    Sourced from mongodb's changelog.

    Changes in 4.x (and how to migrate!)

    Hello dear reader, thank you for adopting version 4.x of the MongoDB Node.js driver, from the bottom of our developer hearts we thank you so much for taking the time to upgrade to our latest and greatest offering of a stunning database experience. We hope you enjoy your upgrade experience and this guide gives you all the answers you are searching for. If anything, and we mean anything, hinders your upgrade experience please let us know via JIRA. We know breaking changes are hard but they are sometimes for the best. Anyway, enjoy the guide, see you at the end!

    Key Changes

    Typescript

    We've migrated the driver to Typescript! Users can now harness the power of type hinting and intellisense in editors that support it to develop their MongoDB applications. Even pure JavaScript projects can benefit from the type definitions with the right linting setup. Along with the type hinting there's consistent and helpful docs formatting that editors should be able to display while developing. Recently we migrated our BSON library to TypeScript as well, this version of the driver pulls in that change.

    Community Types users (@​types/mongodb)

    If you are a user of the community types (@​types/mongodb) there will likely be compilation errors while adopting the types from our codebase. Unfortunately we could not achieve a one to one match in types due to the details of writing the codebase in Typescript vs definitions for the user layer API along with the breaking changes of this major version. Please let us know if there's anything that is a blocker to upgrading on JIRA.

    Node.js Version

    We now require node 12.9 or greater for version 4 of the driver. If that's outside your support matrix at this time, that's okay! Bug fix support for our 3.x branch will not be ending until summer 2022, which has support going back as far as Node.js v4!

    Cursor changes

    Affected classes:

    • AbstractCursor
    • FindCursor
    • AggregationCursor
    • ChangeStreamCursor
      • This is the underlying cursor for ChangeStream
    • ListCollectionsCursor

    Our Cursor implementation has been updated to clarify what is possible before and after execution of an operation. Take this example:

    const cursor = collection.find({ a: 2.3 }).skip(1);
    for await (const doc of cursor) {
      console.log(doc);
      fc.limit(1); // bad.
    }
    

    ... (truncated)

    Commits
    • 4ecaa37 chore(release): 4.1.0
    • ce51e78 fix(NODE-3452): readonly filters not permitted by typings (#2927)
    • c554a7a feat(NODE-3011): Load Balancer Support (#2909)
    • 3c60245 fix(NODE-3513): default command monitoring to off (#2926)
    • 58c1e84 fix(NODE-3510): omit incorrect | void in declaration of Promise overload of...
    • 1fd0244 feat(NODE-2843): implement sessions advanceClusterTime method (#2920)
    • a9c0de8 refactor(NODE-3421): replace MongoDriverError instances with MongoRuntimeErro...
    • b42a1b4 fix(NODE-3058): accept null or undefined anywhere we permit nullish values (#...
    • dc6e2d6 fix(NODE-2883): Aggregate Operation should not require parent parameter (#2918)
    • 967c193 refactor(NODE-3402): implement MongoAPIError and its children (#2891)
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 14
  • How to train entities/slots using corpus?

    How to train entities/slots using corpus?

    Summary

    I'd prefer to use a corpus file instead of hand-coding my training declarations, but it's unclear how to annotate entities/slots in the training file.

    Context

    If I use a corpus consisting of objects per the existing examples (see below example), everything works fine and the intent/answer are correctly recognized.

    {
          "intent": "tell_me_a_joke",
          "utterances": [
            "Tell me a joke",
            "Can you tell me a joke?",
            "I want to hear a joke",
            "make me laugh",
            "tell me something funny"
          ],
          "answers": ["Knock knock"]
        }
    

    However, I want to extract information from some of my intents (see below mock example) to avoid ping-ponging the user for information they've already shared. I've attempted to use % notation as seen below, but it completely breaks that intent altogether it seems.

    {
          "intent": "tell_me_a_joke",
          "utterances": [
            "Tell me a joke about %type%",
            "Can you tell me a %type% joke?",
            "I want to hear a %type% joke",
            "make me laugh",
            "tell me something funny"
          ],
          "answers": ["What type of joke do you want to hear?"]
        }
    

    Example above is trivial, but the general gist is I'd expect the framework to take this and extract out the entity into a slot. However, I have no idea how to approach this if I'm using a corpus. Any examples/guidance would be fabulous.

    Your Environment

    | Software | Version | |----------------------|---------| | nlp.js | 4.10.5 | | node | 13.13.0 | | npm | 6.14.4 | | Operating System | macOS |

    opened by radicand 14
  • feat: Slot Filling, Actions and Trim Entities in Corpus

    feat: Slot Filling, Actions and Trim Entities in Corpus

    Pull Request Template

    PR Checklist

    • [X] I have run npm test locally and all tests are passing.
    • [X] I have added/updated tests for any new behavior.
    • [X] If this is a significant change, an issue has already been created where the problem / solution was discussed: [N/A, or add link to issue here]

    PR Description

    This PR mainly adds needed features to allow to specify Slot-Filling and Actions in a corpus file which was missing so far. Additionally it:

    • fixes the support to specify trim Entities because between needs to be handled differently and betweenLast was missing at all in NLP-Manager.
    • reintroduce the edge splitting for trim entities when overlapping with other entities
    • add a lot of v4-docs for ner-manager, nlp-manager, logics and slot filling

    Also adresses #1001, adresses #917, fixes #814, fixes #702, fixes #440, fixes #408

    opened by Apollon77 13
  • Detect gibberish

    Detect gibberish

    Is your feature request related to a problem? Please describe. Sometimes when chatting with a chatbot application, users end up typing gibberish like: asdasd sadasd or fgfsad dasdsa etc. Is there a way to detect gibberish?

    Describe the solution you'd like Detect gibberish input using NLP

    Describe alternatives you've considered https://github.com/rrenaud/Gibberish-Detector (python based)

    opened by atulmy 13
  • Parallelize computeThetas to reduce training time

    Parallelize computeThetas to reduce training time

    Is your feature request related to a problem? Please describe. Training time can be reduced by using worker_threads (when available based on the node version).

    Describe the solution you'd like Computing Thetas does a descend of gradient that is unique for each classification label, so the calculation of the theta can be theorically executed threaded:

    https://github.com/axa-group/nlp.js/blob/master/lib/math/mathops.js#L165

    enhancement help wanted 
    opened by jesus-seijas-sp 13
  • NerManager is not a constructor

    NerManager is not a constructor

    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?

    opened by jamesst78 12
  • Can't install with NPM (No matching version found for @nlpjs/evaluator@^4.22.2.)

    Can't install with NPM (No matching version found for @nlpjs/evaluator@^4.22.2.)

    Hi, first of all, thanks fo all the work you do here. Today my jenkins process didn't compile, with the next error. To verify that it was a global problem I tryed to install in empty folder and I get the same result. So I guess that is a new bug.

    Describe the bug When I try to install library takes this error:

    $ npm i @nlpjs/basic

    npm ERR! code ETARGET npm ERR! notarget No matching version found for @nlpjs/evaluator@^4.22.2. npm ERR! notarget In most cases you or one of your dependencies are requesting npm ERR! notarget a package version that doesn't exist. npm ERR! notarget npm ERR! notarget It was specified as a dependency of '@nlpjs/basic' npm ERR! notarget

    To Reproduce npm i @nlpjs/basic in a fresh folder NPM Version: 6.14.4

    opened by fred2458 12
  • fix: Fix crash on initial slot fill without a former question asked

    fix: Fix crash on initial slot fill without a former question asked

    Pull Request Template

    PR Checklist

    • [x] I have run npm test locally and all tests are passing.
    • [x] I have added/updated tests for any new behavior.
    • [x] If this is a significant change, an issue has already been created where the problem / solution was discussed: [N/A, or add link to issue here]

    PR Description

    fixes https://github.com/axa-group/nlp.js/issues/1252

    opened by Apollon77 3
  • Cannot read properties of undefined (reading 'latestSlot')

    Cannot read properties of undefined (reading 'latestSlot')

    Describe the bug When trying to fill slots using the corpus file, If the mandatory flag is set to true, it throws the error Cannot read properties of undefined (reading 'latestSlot') Also when i remove the mandatory flag, it still shows the same error.

    To Reproduce Steps to reproduce the behavior:

    1. Using a sample corpus.json file
    {
     "name": "basic conversations",
      "locale": "en-us",
      "entities": {
        "clientName": {
          "trim": [
            {
              "position": "betweenLast",
              "leftWords": ["is", "am"],
              "rightWords": ["."]
            },
            {
              "position": "afterLast",
              "words": ["is", "am"]
            }
          ]
        },
        "location": {
          "trim": [
            {
              "position": "betweenLast",
              "leftWords": ["in", "around"],
              "rightWords": ["today", "currently", "at"]
            },
            {
              "position": "afterLast",
              "words": ["in", "around", "to", "at", "from"]
            }
          ]
        }
      },
    "data": [
        {
          "intent": "user.introduce",
          "utterances": [
            "i am @clientName",
            "my name is @clientName",
          ],
          "answer": [
            "Nice to meet you @clientName.",
            "It's a pleasure to meet you @clientName.",
          ],
          "slotFilling": {
            "clientName": "I'm sorry but i didn't get your name",
            "location": "Where are you from @clientName?"
          }
        },
    }
    
    1. config.json file
    {
      "settings": {
        "nlp": {
          "forceNER": true,
          "corpora": [
            "./corpus.json",
          ]
        }
      },
      "use": ["Basic", "BuiltinMicrosoft", "LangEn"]
    }
    
    1. input i am john in the console
    2. Error produced Cannot read properties of undefined (reading 'latestSlot')

    Expected behavior The console should return one of the specified answers and ask for the users' location according to the data specified in the corpus file. for example Nice to meet you john Where are you from john

    Desktop (please complete the following information):

    • OS: Windows
    • Package version: 4.26.0
    • Node version: v18.12.1
    opened by iamjohnsimeon 9
  • node-nlp does not feature actions and intents?

    node-nlp does not feature actions and intents?

    I followed the documentation with the installation procedure for node-nlp. I managed to get the question and answer feature working which is the only documented feature i found for node-nlp. I checked the examples and they seem to be for NLP.js and not node-nlp.

    And so i am unable to use the actions and intents feature of the package.

    I tried to create a config file, i even tried this

    const manager = new NlpManager({
      languages: ["en"],
      nlu: { useNoneFeature: false },
      corpora: ["./corpora/corpus.json"],
    });
    
    manager.registerActionFunction("getLocalTimeAction", getLocalTimeAction);
    

    but then i get an error TypeError: manager.registerActionFunction is not a function

    Is there any way around this or perhaps i'm missing something?

    opened by iamjohnsimeon 5
  • build(deps): bump json5 from 1.0.1 to 1.0.2

    build(deps): bump json5 from 1.0.1 to 1.0.2

    Bumps json5 from 1.0.1 to 1.0.2.

    Release notes

    Sourced from json5's releases.

    v1.0.2

    • Fix: Properties with the name __proto__ are added to objects and arrays. (#199) This also fixes a prototype pollution vulnerability reported by Jonathan Gregson! (#295). This has been backported to v1. (#298)
    Changelog

    Sourced from json5's changelog.

    Unreleased [code, diff]

    v2.2.3 [code, diff]

    v2.2.2 [code, diff]

    • Fix: Properties with the name __proto__ are added to objects and arrays. (#199) This also fixes a prototype pollution vulnerability reported by Jonathan Gregson! (#295).

    v2.2.1 [code, diff]

    • Fix: Removed dependence on minimist to patch CVE-2021-44906. (#266)

    v2.2.0 [code, diff]

    • New: Accurate and documented TypeScript declarations are now included. There is no need to install @types/json5. (#236, #244)

    v2.1.3 [code, diff]

    • Fix: An out of memory bug when parsing numbers has been fixed. (#228, #229)

    v2.1.2 [code, diff]

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the Security Alerts page.
    dependencies javascript 
    opened by dependabot[bot] 1
  • build(deps): bump @tensorflow/tfjs-node from 3.19.0 to 4.2.0

    build(deps): bump @tensorflow/tfjs-node from 3.19.0 to 4.2.0

    Bumps @tensorflow/tfjs-node from 3.19.0 to 4.2.0.

    Release notes

    Sourced from @​tensorflow/tfjs-node's releases.

    tfjs-v4.2.0

    Core (4.1.0 ==> 4.2.0)

    Bug fixes

    Misc

    • Update monorepo to 4.2.0. (#7226).
    • Use node's util.types.isUint8Array etc for isTypedArray (#7181).
    • Use static getters to get optimizer class names (#7168).
    • Simplify how Optimizers are re-exported in train.ts (#7156).
    • Register optimizers in a centralized location (#7157).
    • Mark all calls to 'op()' as pure (#7155).
    • Refactor type conversion for read back (#7044). Thanks, @​axinging.
    • fix tensor.print() for 0 shaped tensor (#7127).
    • Switch from android 9 to 10 for tests (#7132).
    • Fix the doc error of step operator (#7120). Thanks, @​xhcao.
    • doc: Fix diag() example to make is less confusing. (#7113). Thanks, @​robhybrid.
    • Cast to 'unknown' instead of '{}' in double assertions (#7116).
    • [webgpu] Create tensor from GPUBuffer (#7034). Thanks, @​axinging.
    • Add positive dilation and strides check (#7063).

    Data (4.1.0 ==> 4.2.0)

    Misc

    • Update monorepo to 4.2.0. (#7226).

    Layers (4.1.0 ==> 4.2.0)

    Misc

    • Update monorepo to 4.2.0. (#7226).
    • Switch from android 9 to 10 for tests (#7132).
    • Fix #7104 - tf.initializers.Uniform() ignores seed argument & add tests that replicated the issue, fix wrong serialization name registered for LeCunUniform initializer class (#7108). Thanks, @​adrian-branescu.
    • Bump minimatch from 3.0.4 to 3.1.2 in /tfjs-layers (#7086). Thanks, @​dependabot[bot].

    Converter (4.1.0 ==> 4.2.0)

    Misc

    • Update lockfiles branch tfjs_4.2.0_lockfiles lock files. (#7230).
    • Update monorepo to 4.2.0. (#7226).
    • Update rules_python to 0.16.1 (#7160).
    • Mark tfdf ops as supported by tfjs-converter (#7141).
    • Change dependency from saved_model_cli to saved_model_utils (#7039). Thanks, @​BlaziusMaximus.

    Node (4.1.0 ==> 4.2.0)

    Bug fixes

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies javascript 
    opened by dependabot[bot] 1
  • build(deps): bump axios from 0.26.1 to 1.2.2

    build(deps): bump axios from 0.26.1 to 1.2.2

    Bumps axios from 0.26.1 to 1.2.2.

    Release notes

    Sourced from axios's releases.

    1.2.2

    [1.2.2] - 2022-12-29

    Fixed

    • fix(ci): fix release script inputs #5392
    • fix(ci): prerelease scipts #5377
    • fix(ci): release scripts #5376
    • fix(ci): typescript tests #5375
    • fix: Brotli decompression #5353
    • fix: add missing HttpStatusCode #5345

    Chores

    • chore(ci): set conventional-changelog header config #5406
    • chore(ci): fix automatic contributors resolving #5403
    • chore(ci): improved logging for the contributors list generator #5398
    • chore(ci): fix release action #5397
    • chore(ci): fix version bump script by adding bump argument for target version #5393
    • chore(deps): bump decode-uri-component from 0.2.0 to 0.2.2 #5342
    • chore(ci): GitHub Actions Release script #5384
    • chore(ci): release scripts #5364

    Contributors to this release

    v1.2.1

    [1.2.1] - 2022-12-05

    Changed

    • feat(exports): export mergeConfig #5151

    Fixed

    • fix(CancelledError): include config #4922
    • fix(general): removing multiple/trailing/leading whitespace #5022
    • fix(headers): decompression for responses without Content-Length header #5306
    • fix(webWorker): exception to sending form data in web worker #5139

    Refactors

    • refactor(types): AxiosProgressEvent.event type to any #5308
    • refactor(types): add missing types for static AxiosError.from method #4956

    Chores

    • chore(docs): remove README link to non-existent upgrade guide #5307
    • chore(docs): typo in issue template name #5159

    Contributors to this release

    ... (truncated)

    Changelog

    Sourced from axios's changelog.

    [1.2.2] - 2022-12-29

    Fixed

    • fix(ci): fix release script inputs #5392
    • fix(ci): prerelease scipts #5377
    • fix(ci): release scripts #5376
    • fix(ci): typescript tests #5375
    • fix: Brotli decompression #5353
    • fix: add missing HttpStatusCode #5345

    Chores

    • chore(ci): set conventional-changelog header config #5406
    • chore(ci): fix automatic contributors resolving #5403
    • chore(ci): improved logging for the contributors list generator #5398
    • chore(ci): fix release action #5397
    • chore(ci): fix version bump script by adding bump argument for target version #5393
    • chore(deps): bump decode-uri-component from 0.2.0 to 0.2.2 #5342
    • chore(ci): GitHub Actions Release script #5384
    • chore(ci): release scripts #5364

    Contributors to this release

    [1.2.1] - 2022-12-05

    Changed

    • feat(exports): export mergeConfig #5151

    Fixed

    • fix(CancelledError): include config #4922
    • fix(general): removing multiple/trailing/leading whitespace #5022
    • fix(headers): decompression for responses without Content-Length header #5306
    • fix(webWorker): exception to sending form data in web worker #5139

    Refactors

    • refactor(types): AxiosProgressEvent.event type to any #5308
    • refactor(types): add missing types for static AxiosError.from method #4956

    Chores

    • chore(docs): remove README link to non-existent upgrade guide #5307
    • chore(docs): typo in issue template name #5159

    Contributors to this release

    ... (truncated)

    Commits
    • 8ea4324 chore(docs): added latest release notes
    • 45c4948 chore: build new version
    • 6f74cb1 chore(ci): set conventional-changelog header config; (#5406)
    • 8de391f chore(ci): fix automatic contributors resolving; (#5403)
    • 341f735 chore(ci): improved logging for the contributors list generator;
    • 46085e6 chore(ci): fix release action;
    • f12d01e chore(ci): fix version bump script by adding bump argument for target version;
    • 75217e6 fix(ci): fix release script inputs;
    • c1fc33c chore(deps): bump decode-uri-component from 0.2.0 to 0.2.2
    • 45b29db GitHub Actions Release script; (#5384)
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies javascript 
    opened by dependabot[bot] 1
Releases(4.14.2)
Owner
AXA
The AXA Group is a worldwide leader in insurance and asset management, with 171,000 employees serving 105 million clients in 61 countries.
AXA
A straightforward framework built for automatic proctoring to create online tests, effortlessly

A straightforward framework built for automatic proctoring to create online tests, effortlessly. Explore the docs » Architecture · Features · Local Se

Tushar Nankani 24 Oct 22, 2022
general natural language facilities for node

natural "Natural" is a general natural language facility for nodejs. It offers a broad range of functionalities for natural language processing. Docum

null 10k Jan 9, 2023
Modest natural-language processing

compromise modest natural language processing npm install compromise by Spencer Kelly and many contributors isn't it weird how we can write text, but

spencer kelly 10.4k Dec 30, 2022
Retext is a natural language processor powered by plugins part of the unified collective.

retext is a natural language processor powered by plugins part of the unified collective. Intro retext is an ecosystem of plugins for processing natur

retext 2.2k Dec 29, 2022
:robot: Natural language processing with JavaScript

classifier.js ?? An library for natural language processing with JavaScript Table of Contents Instalation Example of use Auto detection of numeric str

Nathan Firmo 90 Dec 12, 2022
Pure Javascript OCR for more than 100 Languages 📖🎉🖥

Version 2 is now available and under development in the master branch, read a story about v2: Why I refactor tesseract.js v2? Check the support/1.x br

Project Naptha 29.2k Dec 31, 2022
architecture-free neural network library for node.js and the browser

Synaptic Important: Synaptic 2.x is in stage of discussion now! Feel free to participate Synaptic is a javascript neural network library for node.js a

Juan Cazala 6.9k Dec 27, 2022
A JavaScript deep learning and reinforcement learning library.

neurojs is a JavaScript framework for deep learning in the browser. It mainly focuses on reinforcement learning, but can be used for any neural networ

Jan 4.4k Jan 4, 2023
A WebGL accelerated JavaScript library for training and deploying ML models.

TensorFlow.js TensorFlow.js is an open-source hardware-accelerated JavaScript library for training and deploying machine learning models. ⚠️ We recent

null 16.9k Jan 4, 2023
A neural network library built in JavaScript

A flexible neural network library for Node.js and the browser. Check out a live demo of a movie recommendation engine built with Mind. Features Vector

Steven Miller 1.5k Dec 31, 2022
A lightweight library for neural networks that runs anywhere

Synapses A lightweight library for neural networks that runs anywhere! Getting Started Why Sypapses? It's easy Add one dependency to your project. Wri

Dimos Michailidis 65 Nov 9, 2022
A library for prototyping realtime hand detection (bounding box), directly in the browser.

Handtrack.js View a live demo in your browser here. Handtrack.js is a library for prototyping realtime hand detection (bounding box), directly in the

Victor Dibia 2.7k Jan 3, 2023
A speech recognition library running in the browser thanks to a WebAssembly build of Vosk

A speech recognition library running in the browser thanks to a WebAssembly build of Vosk

Ciaran O'Reilly 207 Jan 3, 2023
Linear Regression library in pure Javascript

Lyric Linear Regression library in pure Javascript Lyric can help you analyze any set of x,y series data by building a model that can be used to: Crea

Flurry, Inc. 43 Dec 22, 2020
This is a JS/TS library for accelerated tensor computation intended to be run in the browser.

TensorJS TensorJS How to use Tensors Tensor operations Reading values Data types Converting between backends Onnx model support Optimizations Running

Frithjof Winkelmann 32 Jun 26, 2022
Machine Learning library for node.js

shaman Machine Learning library for node.js Linear Regression shaman supports both simple linear regression and multiple linear regression. It support

Luc Castera 108 Feb 26, 2021
Support Vector Machine (SVM) library for nodejs

node-svm Support Vector Machine (SVM) library for nodejs. Support Vector Machines Wikipedia : Support vector machines are supervised learning models t

Nicolas Panel 296 Nov 6, 2022
machinelearn.js is a Machine Learning library written in Typescript

machinelearn.js is a Machine Learning library written in Typescript. It solves Machine Learning problems and teaches users how Machine Learning algorithms work.

machinelearn.js 522 Jan 2, 2023
FANN (Fast Artificial Neural Network Library) bindings for Node.js

node-fann node-fann is a FANN bindings for Node.js. FANN (Fast Artificial Neural Network Library) is a free open source neural network library, which

Alex Kocharin 186 Oct 31, 2022