Skip to content
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

Extracting custom numbers from an utterance #1284

Open
web3-anon opened this issue Feb 19, 2023 · 5 comments
Open

Extracting custom numbers from an utterance #1284

web3-anon opened this issue Feb 19, 2023 · 5 comments

Comments

@web3-anon
Copy link

I just wanna extract whatever the input variable is... I've tried something like this in my corpus, but it doesn't seem to be working:

    {
      "intent": "id.numbers",
      "utterances": [
        "my id numbers are @number1 and @number2 ETH"
      ],
      "answers": [ "Your numbers are {number1} and {number2}!" ]
    },
@Apollon77
Copy link
Contributor

Which extractors do you have configured? How your code looks like? What tesponse you get? Please provide more details.

@web3-anon
Copy link
Author

Which extractors do you have configured? How your code looks like? What tesponse you get? Please provide more details.

The code looks like the following; it'd be awesome if you could let me know what I'm doing wrong.

        const { NlpManager } = require('node-nlp');
        let string = "example utterance"
        const nlp = new NlpManager({forceNER: true});
        const container = await containerBootstrap();
        container.use(nlp);
        nlp.settings.autoLoad = true;
        nlp.settings.autoSave = true;
        nlp.settings.threshold = 0.4,
        nlp.addLanguage('en');
        nlp.addCorpus('corpus-en.json');
        await nlp.train();
        nlp.nlp.onIntent = onIntent
        let result = await nlp.process(string);

Output continues to look like literal "{number1}" or "$number1" or however I write it, instead of the number provided in the input.

@Apollon77
Copy link
Contributor

Please print out the full result. I just see that you do not initialize any entity extractors, so not sure if that does anything then. I think you need to ad a extractor https://github.com/axa-group/nlp.js/blob/master/docs/v4/ner-manager.md#built-in-entities ... the "default "one or compromise shpuld be able to extract numbers

@thomaskatterexthex
Copy link

thomaskatterexthex commented Feb 24, 2023

exclaimer: My nlp is german so i have to build my number entities myself.
For build in number entity, check how to get the value of a single number if you not have already.
For the example you gave us, you have to do it this way.

{
  "intent": "id.numbers",
  "utterances": [
    "my id numbers are %number% and %number% ETH"
  ],
  "answers": [ "Your numbers are {{[entities.number.items[0].option]}} and {{[entities.number.items[1].option]}}!" ]
}

Explained here kind of:
https://github.com/axa-group/nlp.js/blob/master/docs/v4/slot-filling.md#entities-with-the-same-name
When you have multiple entities with the same name a list is generated and the structure of the object is different.

@Apollon77
Copy link
Contributor

For numbers you can still use the default extractors ... (maybe it is just about the comma vs. point as decimal separator)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants