我有一个单词列表,例如老师,教授,讲师。我想在我的列表中找到所有这些相似含义的单词,并将它们归为 TEACHER 类别。我有很多这样不同的类别。如何在python中找到相似的意思词?任何想法?在我简单地通过以下词搜索之前:
def Make_cluster(title,w1,w2,w3,w4,w5,w6):
try:
print(title," ******")
chartTitles.append(title)
afinn= Afinn()
count=0
totalC=0
rows= extract_data('swansea')
for row in rows:
if w1 in row[0] :
totalC += 1
elif w2 in row[0]:
totalC += 1
elif w3 in row[0]:
totalC += 1
elif w4 in row[0]:
totalC += 1
elif w5 in row[0]:
totalC += 1
elif w6 in row[0]:
totalC += 1
print("Total aspects",totalC)
Make_cluster('TEACHING', 'lecturer', 'course', 'library', 'teacher', 'study ', 'research')
但问题是上面的函数只搜索函数中给出的单词,我不能在一个函数中传递所有这些单词,因为有些类别可能有 5 个,一些 10,一些 20。
有没有办法从一个列表?