hotfix: multi-stage search may result in duplicates (#194)

This commit is contained in:
Gao, Ruiyuan 2024-09-23 15:42:29 +08:00 committed by GitHub
parent 2095ea0d45
commit 917c6d21c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -138,6 +138,7 @@ def find_best_match(user_input, collection, cutoff=0.6, n=1, extra_search_index=
# 如果数量不满足,继续搜索
lower_extra_search_index = {
traditional_to_simple(k.lower()): v for k, v in extra_search_index.items()
if v not in cur_matched_collection
}
matches = real_search(user_input, lower_extra_search_index.keys(), cutoff, n)
cur_matched_collection += [lower_extra_search_index[match] for match in matches]