コード例 #1
0
 def test_multi_word_canonical_term(self):
     TermFactory(canonical_term="people with noses",
                 synonyms=["more jam", "soot", "flies"])
     self.assertListEqual(
         get_synonyms(),
         ["people with noses, more jam, soot, flies"],
     )
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.settings["settings"]["analysis"]["filter"]["synonym"] = {
            "type": "synonym",
            "synonyms": get_synonyms(),
        }
コード例 #3
0
 def test_multiple_synonyms(self):
     TermFactory(canonical_term="foo", synonyms=["fish", "jam"])
     TermFactory(canonical_term="bar",
                 synonyms=["tobogganing", "showers", "toasters"])
     self.assertListEqual(
         get_synonyms(),
         ["foo, fish, jam", "bar, tobogganing, showers, toasters"],
     )
コード例 #4
0
 def test_multi_word_phrase_synonym(self):
     TermFactory(
         canonical_term="foo",
         synonyms=["haircuts arguments", "small things", "rabbits"],
     )
     self.assertListEqual(
         get_synonyms(),
         ["foo, haircuts arguments, small things, rabbits"],
     )
コード例 #5
0
 def test_synonym_cache_can_be_updated(self):
     TermFactory(canonical_term="foo",
                 synonyms=["things that go 'uhh'", "Arthur Negus"])
     cache.set(SYNONYMS_CACHE_KEY, ["foo, colonel gaddafi"])
     self.assertListEqual(cache.get(SYNONYMS_CACHE_KEY),
                          ["foo, colonel gaddafi"])
     self.assertListEqual(get_synonyms(force_update=True),
                          ["foo, things that go 'uhh', arthur negus"])
     self.assertListEqual(cache.get(SYNONYMS_CACHE_KEY),
                          ["foo, things that go 'uhh', arthur negus"])
コード例 #6
0
 def test_basic(self):
     TermFactory(canonical_term="foo", synonyms=["soup", "potatoes"])
     self.assertListEqual(get_synonyms(), ["foo, soup, potatoes"])
コード例 #7
0
    def test_cache_is_used(self):
        cache.set(SYNONYMS_CACHE_KEY, ["foo, eggnog, radiators"])
        self.assertListEqual(get_synonyms(), ["foo, eggnog, radiators"])

        TermFactory(canonical_term="bar", synonyms=["grandmothers"])
        self.assertListEqual(get_synonyms(), ["bar, grandmothers"])
コード例 #8
0
 def test_synonyms_are_lower_cased(self):
     TermFactory(canonical_term="foo",
                 synonyms=["Belgium", "fire", "water"])
     self.assertListEqual(get_synonyms(), ["foo, belgium, fire, water"])
def cache_synonyms_receiver(**kwargs):
    get_synonyms(force_update=True)