nlp.js Extracting custom numbers from an utterance

pdkcd3nj  于 2个月前  发布在  其他
关注(0)|答案(5)|浏览(52)

我只想提取输入变量...我在语料库中尝试过类似的东西,但似乎不起作用:

{
      "intent": "id.numbers",
      "utterances": [
        "my id numbers are @number1 and @number2 ETH"
      ],
      "answers": [ "Your numbers are {number1} and {number2}!" ]
    },
0s0u357o

0s0u357o1#

你配置了哪些提取器?你的代码长什么样?你得到了什么响应?请提供更多细节。

aamkag61

aamkag612#

你配置了哪些提取器?你的代码是什么样的?你得到了什么响应?请提供更多详细信息。
代码如下:如果能告诉我我做错了什么,那就太好了。

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);

输出仍然看起来像是字面量"{number1}"或"$number1",或者无论我怎么写,都不像输入中提供的数字。

2fjabf4q

2fjabf4q3#

请打印出完整结果。我看到你没有初始化任何实体提取器,所以不确定这是否有任何作用。我认为你需要添加一个提取器:https://github.com/axa-group/nlp.js/blob/master/docs/v4/ner-manager.md#built-in-entities ... "default" 或妥协方案应该能够提取数字。

wlwcrazw

wlwcrazw4#

exclaimer: 我的nlp是德语,所以我必须自己构建数字实体。
要构建数字实体,请查看如何获取尚未具有的单个数字的值。
对于您给我们的例子,您需要这样做。

{
  "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]}}!" ]
}

在这里解释一下:
https://github.com/axa-group/nlp.js/blob/master/docs/v4/slot-filling.md#entities-with-the-same-name
当有多个具有相同名称的实体时,会生成一个列表,对象的结构也不同。

5jdjgkvh

5jdjgkvh5#

对于数字,您仍然可以使用默认的提取器...(也许它只是关于逗号与小数点作为小数分隔符)

相关问题