def test_chunk2doc_ranker_driver_min_ranker():
    doc = create_document_to_score()
    driver = SimpleChunk2DocRankDriver()
    executor = MinRanker()
    driver.attach(executor=executor, pea=None)
    driver._apply_all(doc.chunks, doc)
    assert (len(doc.matches) == 4)
    assert (doc.matches[0].id == 40)
    assert (doc.matches[0].score.value == pytest.approx((1 / (1 + 4)), 0.0001))
    assert (doc.matches[1].id == 50)
    assert (doc.matches[1].score.value == pytest.approx((1 / (1 + 5)), 0.0001))
    assert (doc.matches[2].id == 60)
    assert (doc.matches[2].score.value == pytest.approx((1 / (1 + 6)), 0.0001))
    assert (doc.matches[3].id == 70)
    assert (doc.matches[3].score.value == pytest.approx((1 / (1 + 7)), 0.0001))
    for match in doc.matches:
        assert (match.score.ref_id == doc.id)
def test_chunk2doc_ranker_driver_min_ranker():
    doc = create_document_to_score()
    driver = SimpleChunk2DocRankDriver()
    executor = MinRanker()
    driver.attach(executor=executor, pea=None)
    driver._apply_all(doc.chunks, doc)
    assert (len(doc.matches) == 4)
    assert (doc.matches[0].id == 40)
    assert (doc.matches[0].score.value == pytest.approx((1 / (1 + 4)), 0.0001))
    assert (doc.matches[1].id == 50)
    assert (doc.matches[1].score.value == pytest.approx((1 / (1 + 5)), 0.0001))
    assert (doc.matches[2].id == 60)
    assert (doc.matches[2].score.value == pytest.approx((1 / (1 + 6)), 0.0001))
    assert (doc.matches[3].id == 70)
    assert (doc.matches[3].score.value == pytest.approx((1 / (1 + 7)), 0.0001))
    for match in doc.matches:
        assert (match.score.ref_id == doc.id)