def test_multi_match_raises_error_when_query_not_Doc( searcher: FuzzySearcher, nlp: Language ) -> None: """It raises a TypeError if query is not a Doc object.""" doc = nlp("G-rant Anderson lives in TN.") query = "xenomorph" with pytest.raises(TypeError): searcher.multi_match(doc, query)
def test_multi_match_return_empty_list_when_no_matches_after_adjust( searcher: FuzzySearcher, nlp: Language ) -> None: """It returns an empty list if no fuzzy matches meet min_r2 threshold.""" doc = nlp("G-rant Anderson lives in TN.") query = nlp("Garth, Anderdella") assert searcher.multi_match(doc, query) == []
def test_multi_match_with_n_less_than_actual_matches( searcher: FuzzySearcher, nlp: Language ) -> None: """It returns the n best fuzzy matches that meet threshold correctly sorted.""" doc = nlp("cow, cow, cow, cow") query = nlp("cow") assert searcher.multi_match(doc, query, n=2) == [(0, 1, 100), (2, 3, 100)]
def test_multi_match_finds_best_matches(searcher: FuzzySearcher, nlp: Language) -> None: """It returns all the fuzzy matches that meet threshold correctly sorted.""" doc = nlp("chiken from Popeyes is better than chken from Chick-fil-A") query = nlp("chicken") assert searcher.multi_match(doc, query, ignore_case=False) == [ (0, 1, 92), (6, 7, 83), ]