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

Cannot read properties of undefined (reading 'latestSlot')

iamjohnseun opened this issue · comments

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

Hi,

there is no mandatory in your example file? Please show the code and olease shjow the full error message

In the version on GitHub there were many changes around that, so it could be an idea to retest this after next release - but if you provide more infos I could also have a look to make sure it is fixed

With the mandatory option set to true, Here is the full error,

TypeError: Cannot read properties of undefined (reading 'latestSlot')
    at SlotManager.process (C:\Program Files\www\bot\node_modules\@nlpjs\slot\src\slot-manager.js:295:36)
    at Nlp.process (C:\Program Files\www\bot\node_modules\@nlpjs\nlp\src\nlp.js:737:28)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Bot.process (C:\Program Files\www\bot\assistant\core\index.js:58:24)
    at async Interface.<anonymous> (C:\Program Files\www\bot\assistant\index.js:16:18)

Ahh cool ... @eric-lara released a new version... will check.

DO you have your full code please that I can reproduce it? Or tell here to set in your corpus above a mandatory true

Ok ... now I understand (after reading several times) that it has nothing to do with mandaory.

Can you please tell which text you process with the corpus above?

I tried to process i am john

const dock = await dockStart();
const nlp = dock.get("nlp");
const response = await nlp.process("i am john");
console.log(response);

hehe ... tries the same (also john) .. was able to reporoduce, will do PR for fix

Do you know when the npm version will be released?
Would you advice downloading the github version and replacing the npm version?

Would you advice downloading the github version and replacing the npm version?

No you can't! nlp.js is a monrepo ... you can not install the github version as easy as normal. This will not work. So best way to unblock you is to change manually the code until a fix gets released

@iamjohnsimeon fix released by eric too