简体   繁体   English

使用NTLK与主题相关的单词(另一个单词)

[英]words related to a topic (another word) using NTLK

I'm working on building my own virtual assistant based on intent<->action mechanism and want to run some NLP on sentences that my users write. 我正在基于intent <-> action机制构建自己的虚拟助手,并希望对用户编写的句子运行一些NLP。

I want to find out words related to a topic(another word) so that I can define an intent, for example: 我想找出与某个主题相关的词(另一个词),以便定义意图,例如:

If a user asks: Will it rain tomorrow? 如果用户问:明天会下雨吗? What's the weather today? 今天天气如何? is it sunny? 是晴天吗? Is if going to be windy this afternoon? 今天下午有风吗?

I want to be able to say that rain, weather, sunny, sun are related to the intent called weather so that I can communicate with the relevant API and retrieve the requested information. 我想说雨,天气,晴天,太阳与所谓的天气有关,这样我就可以与相关的API进行通信并检索所请求的信息。

I'm currently working with Python 3 and NLTK but using synonyms, path to parent and similarity doesn't really do the trick: 我目前正在使用Python 3和NLTK,但使用同义词,父级路径和相似性并不能真正解决问题:

wordFromList1 = wn.synsets('weather')[0]
wordFromList2 = wn.synsets('cold')[0]
value = wn.wup_similarity(wordFromList1, wordFromList2)
print(value)
---------------------------
0.1

You can see that the similarity here for cold and weather is really weak. 您可以看到这里的寒冷和天气的相似性确实很弱。 Any suggestions? 有什么建议么?

Thanks, 谢谢,

Yeah, don't use wordnet for this! 是的,请勿使用wordnet! it might be (very loosely) correlated to solving what you want but will yield horrendous accuracy and recall unless you engineer the hell out of it. 它可能(非常松散地)与解决您想要的问题相关,但是除非您从根本上解决问题,否则它会产生可怕的准确性和召回率。 For practical results what you need to do is look at things like LSA, LDA or word embeddings, something along those lines 为获得实际结果,您需要做的是查看LSA,LDA或词嵌入等内容,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM