我只是按照这个https://github.com/axa-group/nlp.js/issues/126#issuecomment-444852649
但我得到的分数与示例中的不同。https://runkit.com/jesus-seijas-sp/5c0910e71539810012150767
有什么我想念的规则吗?
我只想使用 BayesClassifier
我在用 :"node-nlp": "^2.4.2"
const { BayesClassifier, NlpManager } = require('node-nlp');
async function main() {
const bayes = new BayesClassifier();
const manager = new NlpManager({
languages: ['en'],
classifier: bayes,
useNeural: false,
});
manager.addDocument('en', 'Hello', 'greet');
manager.addDocument('en', 'Good evening', 'greet');
manager.addDocument('en', 'Good morning', 'greet');
manager.addDocument('en', "I've lost my keys", 'keys');
manager.addDocument('en', "I don't find my keys", 'keys');
manager.addDocument('en', "I don't know where are my keys", 'keys');
await manager.train();
const result = await manager.process('Where are my keys');
console.log(result);
}
main();
结果
{ locale: 'en',
localeIso2: 'en',
language: 'English',
utterance: 'Where are my keys',
classification:
[ { label: 'keys', value: 0.055555555555555546 },
{ label: 'greet', value: 0.006172839506172837 } ],
intent: 'keys',
domain: 'default',
score: 0.055555555555555546,
entities: [],
sentiment:
{ score: 0,
comparative: 0,
vote: 'neutral',
numWords: 4,
numHits: 0,
type: 'senticon',
language: 'en' } }