我有一个完美的代码,但执行需要花费很多时间,这里是代码:
result_lesk=[]
result=[]
for i in range (0,len(texto_palabras)):
result_lesk.append(lesk(texto_palabras,texto_palabras[i]))
print(result_lesk)
print (len(result_lesk))
print(len(result))
for i in range(0,len(result_lesk)):
if(result_lesk[i] is not None):
result.append(result_lesk[i])
print(result)
result=set(result)
result=list(result)
print(result)
for i in range(0,len(result)):
for synset in wn.all_synsets():
if(result[i]==synset):
best_synset_lemma_names=synset.lemma_names()
len_best_synset_lemma_names=len(best_synset_lemma_names)
for i in range(0,len(best_synset_lemma_names)):
texto_palabras.append(best_synset_lemma_names[i])
简而言之,我有一个文本,我需要消除歧义,然后对于每个synset(lesk结果),我必须搜索lemmas名称(同义词)以便在其他进程中添加。 问题是lesk结果只是一个字符串,我需要与wn.synset.lemma_names()的synset 知道我如何优化吗? 谢谢!