所以我看到了这个很棒的natural language processing in javascript我想知道如何进行基本的语境化?
比方说,我想抓紧时间。
通过做这样的事情:
var word = nlp(`What's the time`)
console.log(word.match('time').found)
我得到一个 true
bool 值,因为 time
词存在。但是我想做的是例如
nlp('What's the time')
和 nlp('What time is it')
值将为 true 但如果 nlp('Time is gold')
该值将为 false,因为用户没有询问时间。
这个库可以吗?任何帮助将不胜感激。
最佳答案
听起来你想做的是Intent Recognition,这通常被视为分类问题。这article概述了一种方法;看一下训练数据:
training_data.append({"class":"greeting", "sentence":"how are you?"})
training_data.append({"class":"greeting", "sentence":"how is your day?"})
training_data.append({"class":"greeting", "sentence":"good day"})
training_data.append({"class":"greeting", "sentence":"how is it going today?"})
training_data.append({"class":"goodbye", "sentence":"have a nice day"})
training_data.append({"class":"goodbye", "sentence":"see you later"})
training_data.append({"class":"goodbye", "sentence":"have a nice day"})
training_data.append({"class":"goodbye", "sentence":"talk to you soon"})
training_data.append({"class":"sandwich", "sentence":"make me a sandwich"})
training_data.append({"class":"sandwich", "sentence":"can you make a sandwich?"})
training_data.append({"class":"sandwich", "sentence":"having a sandwich today?"})
training_data.append({"class":"sandwich", "sentence":"what's for lunch?"})
Compromise 没有任何文本分类功能,因此在这里对您没有帮助。
关于javascript - 如何使用 nlp-compromise 在 JavaScript 中进行基本的语境化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44776739/