test_similarity.py 文件源码

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

项目:rltk 作者: usc-isi-i2 项目源码 文件源码
def test_hybrid_jaccard_similarity():
    # use a fixed test cases here only to test hybrid jaccard itself.
    def test_function(m, n):
        if m == 'a' and n == 'p':
            return 0.7
        if m == 'a' and n == 'q':
            return 0.8
        if m == 'b' and n == 'p':
            return 0.5
        if m == 'b' and n == 'q':
            return 0.9
        if m == 'c' and n == 'p':
            return 0.2
        if m == 'c' and n == 'q':
            return 0.1

    assert pytest.approx(hybrid_jaccard_similarity(set(['a','b','c']), set(['p', 'q']), function=test_function),
                         0.001) == 0.5333
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号