-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't extract numbers from intents. #5
Comments
Just to clarify, the console output I'm getting while trying this out is below. Notice how I start by saying That aside, I reply with Now, also notice that on this last intent handler, I log
and there's an
|
Hello there, we just checked and it seems that the built-in entity extraction of nlp.js is not enabled by default. You will need to do the following:
We will probably make this easier in the future, but for now, this workaround should work. If you have any more questions, just let us know. |
Thank you @m-ripper. I've tried your suggestion but I'm getting this error:
How did you get around this? Also, how do you declare the type of NLP.js in the model? Is this correct?
Thanks, |
@m-ripper, I got around the typescript compilation problem by switching to Javascript, but I'm still facing a few issues. Could you update one of the templates with a working example? Here's what's happening:
Here's my adapted HelloWorld project to test this. 'use strict';
const { App } = require('jovo-framework');
const { Alexa } = require('jovo-platform-alexa');
const { GoogleAssistant } = require('jovo-platform-googleassistant');
const { JovoDebugger } = require('jovo-plugin-debugger');
const { FileDb } = require('jovo-db-filedb');
const { WebPlatform } = require ('jovo-platform-web');
const { NlpjsNlu } = require ('jovo-nlu-nlpjs');
const { BuiltinDefault } = require ('@nlpjs/builtin-default')
const { LangEn } = require ('@nlpjs/lang-en')
const app = new App()
const webPlatform = new WebPlatform();
const nlpjsNlu = new NlpjsNlu({
setupModelCallback: async (handleRequest, nlp) => {
// force entity extraction
nlp.forceNER = true;
// register module for entity extraction
nlp.container.use(BuiltinDefault, 'extract-builtin');
// register module for English
nlp.use(LangEn);
// add corpus via path to the models directory
// you might change it to pass an absolute path
nlpjsNlu.addCorpus('/Users/miguelangel/ws/node/my-embeddedchat/hello/models');
},
})
webPlatform.use(nlpjsNlu);
app.use(
new Alexa(),
new GoogleAssistant(),
webPlatform,
new JovoDebugger(),
new FileDb()
);
app.setHandler({
LAUNCH() {
return this.toIntent('HelloWorldIntent');
},
ON_REQUEST(){
console.log(`**** ON_REQUEST Inputs: ${JSON.stringify(this.$inputs)}`)
},
SumsIntent(){
console.log(`**** SumsIntent with ${this.$inputs}`)
let sum = parseFloat(this.$inputs.firstNumber.key) + parseFloat(this.$inputs.secondNumber.key)
this.tell(`The answer is ${sum}`)
},
HelloWorldIntent() {
this.ask("Hello World! What's your name?", 'Please tell me your name.');
},
MyNameIsIntent() {
this.tell('Hey ' + this.$inputs.name.value + ', nice to meet you!');
},
Unhandled(){
console.log(`**** Unhandled`)
console.log(`this.getMappedIntentName: ${this.getMappedIntentName()}`)
console.log(`this.getRoute: ${JSON.stringify(this.getRoute())}`)
this.tell(`Darn! can't do that yet.`)
}
});
module.exports = { app }; Here's my model for my {
"name": "SumsIntent",
"phrases": [
"how much is ${firstNumber} plus {secondNumber}",
"add ${firstNumber} plus {secondNumber}",
"add ${firstNumber} and {secondNumber}",
"${firstNumber} plus {secondNumber}"
],
"inputs": [
{
"name": "firstNumber",
"type": {
"alexa": "AMAZON.NUMBER",
"googleAssistant": "actions.type.Number"
}
},
{
"name": "secondNumber",
"type": {
"alexa": "AMAZON.NUMBER",
"googleAssistant": "actions.type.Number"
}
}
]
} Notice how I removed the Here are the request and response.
Notice how just before the |
I've tried everything I could think of and have not been able to extract a number from an intent sent by the
JovoWebClient
lib. Meaning thatthis.$inputs
is always empty —i.e.{}
.My intent looks like this in
models/en-US.json
:It works perfectly fine with Alexa or Google Assistant, but won't work when the request comes from a client web application. I've also tried
"nlpjs": "Number"
,"nlpjs": "integer"
and"nlpjs": "Integer"
.I noticed that
$request
coming from Alexa and Google assistant bears"type": "IntentRequest"
, but intents coming from theJovoWebClient
lib bear"type": "TEXT"
, so then I tried sending the request as aRequestType.Intent
from the web client:This resulted in the
$request
bearing"type": "INTENT"
, but that didn't do the trick either.I also noticed that
this.$nlu
carries NLP.js entities (https://github.com/axa-group/nlp.js/blob/master/docs/v3/builtin-entity-extraction.md#number-extraction) but there's no resolution.The text was updated successfully, but these errors were encountered: