def get_gallery_closer_title_from_gallery_values(original: str, gallery_datas: List[GalleryData], cutoff: float) -> ResultContainer:
result = ResultContainer()
compare_titles = []
for gallery_dict in gallery_datas:
compare_titles.append(gallery_dict.title)
matches = difflib.get_close_matches(original, compare_titles, 1, cutoff) # type: ignore
if len(matches) == 0:
return result
result.match_title = str(matches[0])
for i, compare_title in enumerate(compare_titles):
if compare_title == result.match_title:
result.match_values = gallery_datas[i]
result.match_link = gallery_datas[i].link
gallery_datas[i].link = None
return result
评论列表
文章目录