Esempio n. 1
0
def test_probabilistic_nonprobabilistic_match_ndedup(candidate_pairs):
    candidates = _zip_candidates(candidate_pairs)
    solution_probabilistic = probabilistic_greedy_solve(
        candidates, merge_threshold=1, deduplicated=False)
    solution_nonprobabilistic = greedy_solve(candidates)

    # We don't care about the order
    solution_probabilistic = frozenset(map(frozenset, solution_probabilistic))
    solution_nonprobabilistic = frozenset(map(frozenset,
                                              solution_nonprobabilistic))

    assert solution_probabilistic == solution_nonprobabilistic
Esempio n. 2
0
def test_probabilistic_greedy():
    candidates = [(.9, ((0, 0), (0, 1))), (.8, ((1, 0), (1, 1))),
                  (.7, ((0, 0), (1, 0))), (.6, ((0, 0), (1, 1))),
                  (.5, ((0, 1), (1, 0)))]

    result = probabilistic_greedy_solve(_zip_candidates(candidates),
                                        merge_threshold=0.,
                                        deduplicated=True)
    _compare_matching(result, [{(0, 0), (1, 0)}])

    result = probabilistic_greedy_solve(_zip_candidates(candidates),
                                        merge_threshold=.75,
                                        deduplicated=True)
    _compare_matching(result, [{(0, 0), (1, 0)}])

    result = probabilistic_greedy_solve(_zip_candidates(candidates),
                                        merge_threshold=.76,
                                        deduplicated=True)
    _compare_matching(result, [{(0, 0), (1, 0)}])

    result = probabilistic_greedy_solve(_zip_candidates(candidates),
                                        merge_threshold=1.,
                                        deduplicated=True)
    _compare_matching(result, [{(0, 0), (1, 0)}])

    result = probabilistic_greedy_solve(_zip_candidates(candidates),
                                        merge_threshold=0.0,
                                        deduplicated=False)
    _compare_matching(result, [{(0, 0), (1, 0), (0, 1), (1, 1)}])

    result = probabilistic_greedy_solve(_zip_candidates(candidates),
                                        merge_threshold=0.75,
                                        deduplicated=False)
    _compare_matching(result, [{(0, 0), (1, 0), (0, 1), (1, 1)}])

    result = probabilistic_greedy_solve(_zip_candidates(candidates),
                                        merge_threshold=0.76,
                                        deduplicated=False)
    _compare_matching(result, [{(0, 0), (0, 1)}, {(1, 0), (1, 1)}])

    result = probabilistic_greedy_solve(_zip_candidates(candidates),
                                        merge_threshold=1,
                                        deduplicated=False)
    _compare_matching(result, [{(0, 0), (0, 1)}, {(1, 0), (1, 1)}])