python - 无法在 python 中找到 wordnet 同义词集
问题描述
我有功能
def find_n_similar():
word = input("please enter a word: ")
word_syntest = wordnet.synsets(word)[0]
print(word_syntest)
similarity_rate = {}
with open("1-1000.txt", 'r') as file:
file_words = file.read().split("\n")
print(file_words)
for file_word in file_words:
file_word_syntest = wordnet.synsets(file_word)
similarity_rate.update({f"{file_word}": word_syntest.path_similarity(file_word_syntest)})
如果我输入“the”、“of”等,它会抛出异常:IndexError: list index out of range
我怎样才能找到这些词的同义词?
解决方案
推荐阅读
- ios - IOS App中的AppAuth,更新授权代码时发出问题/警报短暂显示然后消失
- python - Python - Pandas 百分比分布小于 80%
- r - 有效地将每行值转换为另一种货币
- javascript - 反应没有正确更新状态
- python - 调用没有方法调用运算符的函数
- android - 拉SwipeRefreshLayout时如何防止RecyclerView出现重复数据?
- xamarin.forms - 如何将条目绑定到命令?
- java - 无法在 NetBeans IDE 中使用 Embedded Derby 连接生成 Hibernate 逆向工程
- java - 在 O(n) java8 流中查找两个列表的交集
- javascript - 在数组推送中破坏 es6