jovo-model icon indicating copy to clipboard operation
jovo-model copied to clipboard

Fix jovo-model-nlpjs to allow for regex and built-in entities for number, ordinal, date, time

Open rmtuckerphx opened this issue 2 years ago • 0 comments

I'm submitting a...

  • [ ] Bug report
  • [x] Feature request
  • [ ] Documentation issue or request
  • [ ] Other... Please describe:

Expected Behavior

NLP.js allows for specifying entities of various types including regex and depending on configured settings can handle various builtin types such as number, ordinal, date, and time.

These built-in entity types are defined based on specified packages such as builtin-microsoft: https://github.com/axa-group/nlp.js/blob/581b945b19a4c0205d85e4b575b6542a4b69372b/packages/builtin-microsoft/src/builtin-microsoft.js#L85-L103

The JovoModel v4 structure is converted to an NLP.js corpus.json file but it appears that it only supports entities of type enum as can be seen from the interface that expects an options: https://github.com/jovotech/jovo-model/blob/8880b156132871a2a4a4dc6369352f553f5ac2dc/packages/jovo-model-nlpjs/src/Interfaces.ts#L15-L26

Here is a sample corpus that shows an enum entity (hero) and a regex entity (email):

{
  "entities": {
    "hero": {
      "options": {
        "spiderman": ["spiderman", "spider-man"],
        "ironman": ["ironman", "iron-man"],
        "thor": ["thor"]
      }
    },
    "email": "/\\b(\\w[-._\\w]*\\w@\\w[-._\\w]*\\w\\.\\w{2,3})\\b/gi"
  }
}

Full sample is here

Tasks:

  1. Figure out a format when specifying a non-enum entity in the Jovo Model v4 format. Something like:
"entities": {
  "animal": {
    "type": "ANIMAL_SYNONYMS" // enum type
  },
  "size": {
    "type": "ANIMAL_SIZE" // enum type
  },
  "number": {
    "type": {
      "nlpjs": "builtin-microsoft::Number"
    }
  },
  "email": {
    "type": {
      "nlpjs": "regex::/\\b(\\w[-._\\w]*\\w@\\w[-._\\w]*\\w\\.\\w{2,3})\\b/gi"
    }
  }
}
  1. Update jovo-model-nlpjs so that it can handle non-enum entities
  2. Allow passing the needed configuration values to NLP.js whether you are using that as the NLU for the Jovo Debugger on in your Jovo app.

Current Behavior

Can only use enum types in NLP.js when you specify the model in Jovo Model v4 format.

Error Log

No error.

Your Environment

  • Jovo Framework version used: 4.2.12
  • Operating System: Windows 10 10.0.22000

rmtuckerphx avatar May 03 '22 05:05 rmtuckerphx