comparison.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:pandachaika 作者: pandabuilder 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号