Exemplo n.º 1
0
    def test_to_list_includes_all_words(self):
        words = ["bat", "cat"]
        token_set = TokenSet.from_list(words)

        assert set(words) == set(token_set.to_list())
Exemplo n.º 2
0
    def test_from_list_is_minimal(self):
        token_set = TokenSet.from_list(["ac", "dc"])
        ac_node = token_set.edges["a"].edges["c"]
        dc_node = token_set.edges["d"].edges["c"]

        assert ac_node == dc_node
Exemplo n.º 3
0
 def test_from_list_with_unsorted_list(self):
     with pytest.raises(BaseLunrException):
         TokenSet.from_list(["z", "a"])
Exemplo n.º 4
0
 def test_from_list_with_sorted_list(self):
     token_set = TokenSet.from_list(["a", "z"])
     assert ["a", "z"] == sorted(token_set.to_list())
Exemplo n.º 5
0
 def _create_token_set(self):
     """Creates a token set of all tokens in the index using `lunr.TokenSet`
     """
     self.token_set = TokenSet.from_list(
         sorted(list(self.inverted_index.keys())))