问题描述
使用文本数据我使用“wiki_ru_wordnet”库来查找同义词并将所有单词组替换为一个。后来我用 networkx 来查找孤立的组。
def get_dict_synsets(texts):
wikiwordnet = WikiWordnet()
G=nx.Graph()
for text in texts:
s = set()
synsets = wikiwordnet.get_synsets(text)
for synset in synsets:
for w in synset.get_words():
if text != w.lemma():
G.add_edge(text,w.lemma())
d = {}
for g in nx.connected_components(G):
default_lemma = g.pop()
d.update(dict.fromkeys(g,default_lemma))
d[default_lemma] = default_lemma
return d,G
下面是一个词描述的一组词的例子:
在我看来,我不能使用它,因为不是真正同义词的词属于同一组。好的结果会像下一张图片:
[![在此处输入图片描述][2]][2]
我如何更正我的结果?我有想法 - 使用 networx.clustering 但不知道如何... [2]:https://i.stack.imgur.com/Hi2C8.png
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)