def test_best_match_raises_error_when_query_not_Doc( searcher: FuzzySearcher, nlp: Language ) -> None: """Raises a Type error if query is not a Doc object.""" doc = nlp("G-rant Anderson lives in TN.") query = "xenomorph" with pytest.raises(TypeError): searcher.best_match(doc, query)
def test_best_match_return_none_when_no_matches( searcher: FuzzySearcher, nlp: Language ) -> None: """It returns None if no fuzzy match meets threshold.""" doc = nlp("G-rant Anderson lives in TN.") query = nlp("xenomorph") assert searcher.best_match(doc, query) is None
def test_best_match_finds_best_match(searcher: FuzzySearcher, nlp: Language) -> None: """It finds the single best fuzzy match that meets threshold.""" doc = nlp("G-rant Anderson lives in TN.") query = nlp("Grant Andersen") assert searcher.best_match(doc, query) == (0, 4, 90)