Commit b114ca66 authored by 于飞's avatar 于飞

滤掉同义词之前,先去重

parent 5331e365
......@@ -262,8 +262,12 @@ def filter_similar(key_words: list, similar_words: list) -> list:
print(result) # 输出:['高兴', '生气']
这个例子中,函数会保留“高兴”作为同义词组的代表词,并保留“生气”作为另一组的代表。
"""
#先对key_words去重
unique_keywords = list(set(key_words))
f_words = []
for word in key_words:
for word in unique_keywords:
# 检查这个词或它的同义词是否已经在 f_words 中
found_similar = False
for synonym_group in similar_words:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment