main.py 文件源码

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

项目:RottenCrawler 作者: kevin940726 项目源码 文件源码
def newScore(movie):
    critic_num = len(token_dict[movie["movieTitle"]]["critics"])
    N = len(token_dict[movie["movieTitle"]]["reviews"])
    C = cosine[movie["movieTitle"]][critic_num:, critic_num:]
    R = map(lambda x: x['score'], movie['reviews'])

    print C.shape
    # exclude self similarity
    # np.fill_diagonal(C, 0)
    # normalize
    row_sums = C.sum(axis=1)
    C = C / row_sums[:, np.newaxis]
    # calculate new score
    new_score = np.dot(C, R)

    # update new score
    new_review = movie['reviews']
    map(lambda x, y: x.update({'newScore': y}), new_review, new_score)

    testing = map(lambda x: abs(x['score'] - x['newScore']) < 5, new_review)
    print np.sum(testing)

    return new_review
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号