def setUp(self): self.maxDiff = None options.cfg = argparse.Namespace() options.cfg.number_of_tokens = 0 options.cfg.limit_matches = False options.cfg.regexp = False options.cfg.query_case_sensitive = False options.get_configuration_type = lambda: SQL_MYSQL self.Session = MockOptions() self.Session.Resource = self.resource self.Session.Lexicon = None self.Session.Corpus = None COCAToken.set_pos_check_function(self.pos_check_function)
def test_token_conditions_lemmatized_deep_2(self): S = "#/a*/" token = COCAToken(S, self.Session) d = self.resource.get_token_conditions(0, token) self.assertEqual( self.simple(d["word"][0]), self.simple(""" COQ_LEMMA_1.Lemma IN (SELECT DISTINCT Lemma FROM Lexicon AS COQ_WORD_1 INNER JOIN Lemmas AS COQ_LEMMA_1 ON COQ_LEMMA_1.LemmaId = COQ_WORD_1.LemmaId WHERE (COQ_WORD_1.Transcript LIKE 'a%'))"""))
def test_token_conditions_lemmatized_flat_1(self): self.Session.Resource = self.flat_resource S = "#abc" token = COCAToken(S, self.Session) d = self.flat_resource.get_token_conditions(0, token) self.assertEqual( self.simple(d["word"][0]), self.simple(""" COQ_WORD_1.Lemma IN (SELECT DISTINCT Lemma FROM Lexicon AS COQ_WORD_1 WHERE (COQ_WORD_1.Word = 'abc'))""")) self.Session.Resource = self.resource
def test_token_condition_empty_4(self): token = COCAToken("a*.[*]") d = self.resource.get_token_conditions(0, token) self.assertDictEqual(d, {"word": ["COQ_WORD_1.Word LIKE 'a%'"]})
def test_token_condition_empty_3(self): token = COCAToken("*.[n*]") d = self.resource.get_token_conditions(0, token) self.assertDictEqual(d, {"word": ["COQ_WORD_1.POS LIKE 'n%'"]})
def test_token_condition_empty_2(self): token = COCAToken("*.[*]") d = self.resource.get_token_conditions(0, token) self.assertDictEqual(d, {})
def test_get_token_conditions_quote_char_2(self): token = COCAToken("'ll|ll") d = self.resource.get_token_conditions(0, token) self.assertDictEqual(d, {"word": ["COQ_WORD_1.Word IN ('''ll', 'll')"]})
def test_get_token_conditions_5(self): token = COCAToken("*'ll") d = self.resource.get_token_conditions(0, token) self.assertDictEqual(d, {"word": ["COQ_WORD_1.Word LIKE '%''ll'"]})
def test_get_token_conditions_3(self): token = COCAToken("[a*|b*]") d = self.resource.get_token_conditions(0, token) self.assertDictEqual(d, {"lemma": ["COQ_LEMMA_1.Lemma LIKE 'a%' OR COQ_LEMMA_1.Lemma LIKE 'b%'"]})
def test_get_token_conditions_2(self): token = COCAToken("a*|b*.[n*]") d = self.resource.get_token_conditions(0, token) self.assertDictEqual(d, {"word": ["COQ_WORD_1.Word LIKE 'a%' OR COQ_WORD_1.Word LIKE 'b%'", "COQ_WORD_1.POS LIKE 'n%'"]})