users.py 文件源码

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

项目:recko 作者: vargi 项目源码 文件源码
def calculate_euclidaen_distance(self, user_keywords, matched_article):
        "Calculate the euclidaen distance between matched url and recored url"
        new_article_kws = {i['name']: i['score'] for i in user_keywords if i['score'] >= 25}
        matched_article_kws = {i['name']: i['score'] for i in matched_article.keywords if i['score'] >= 25}
        all_keywords = [i for i in [i["name"] for i in user_keywords if i["score"] >= 25]] + \
                       [i for i in [i["name"] for i in matched_article.keywords if i["score"] >= 25]]

        a = tuple([new_article_kws.get(i, 0) for i in all_keywords])
        b = tuple([matched_article_kws.get(i, 0) for i in all_keywords])
        try:
            dst = distance.euclidean(a,b)
            return dst
        except:
            return 0
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号