Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用nlp折衷在JavaScript中实现基本的上下文化?_Javascript_Machine Learning_Nlp_Nlp Compromise - Fatal编程技术网

如何使用nlp折衷在JavaScript中实现基本的上下文化?

如何使用nlp折衷在JavaScript中实现基本的上下文化?,javascript,machine-learning,nlp,nlp-compromise,Javascript,Machine Learning,Nlp,Nlp Compromise,所以我看到了这个很棒的东西,我想知道我怎样才能做一个基本的情境化 比如说,我想得到时间 通过这样做: var word = nlp(`What's the time`) console.log(word.match('time').found) 我得到一个true布尔值,因为time单词存在。但我想做的是举个例子 nlp('What's time')和nlp('What time is')值将为真,但如果nlp('time is gold')值将为假,因为用户没有要求时间 这个图书馆有可能吗

所以我看到了这个很棒的东西,我想知道我怎样才能做一个基本的情境化

比如说,我想得到时间

通过这样做:

var word = nlp(`What's the time`)

console.log(word.match('time').found)
我得到一个
true
布尔值,因为
time
单词存在。但我想做的是举个例子

nlp('What's time')
nlp('What time is')
值将为真,但如果
nlp('time is gold')
值将为假,因为用户没有要求时间


这个图书馆有可能吗?任何帮助都将不胜感激。

听起来您想要做的是意图识别,这通常被视为一个分类问题。这给出了一种方法的概述;请看一下培训数据:

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?"})
“妥协”没有任何用于文本分类的功能,因此在这里对您没有帮助。

是的,这感觉像是一个统计分类问题

但是,如果您知道(或机器学习的)表明意图的句子模板,您可以使用


我会调查的。非常感谢。
//what time is..
if(doc.has('#QuestionWord time #Copula')){
  return true
}
//time is fun..
if(doc.has('time #Copula #Adjective')){
  return false
}