def test_could_compare_with_other_token(self):
     token1 = Token("xxx", original="bla")
     token2 = Token("yyy", original="bla")
     token3 = Token("yyy", original="bleh")
     self.assertTrue(token1 == token2)
     self.assertTrue(token2 == token1)
     self.assertFalse(token1 == token3)
     self.assertFalse(token3 == token1)
 def setUp(self):
     sentence = Sample("sample")
     self.first = Token("one", "Une")
     sentence.append(self.first)
     self.second = Token("two", "phrase")
     sentence.append(self.second)
     self.third = Token("three", "simple")
     sentence.append(self.third)
Пример #3
0
 def test_should_append_token_and_update_its_position(self):
     sample = Sample("xxx")
     token = Token("yyy", original="bla")
     sample.append(token)
     self.assertIn(token, sample)
     self.assertEqual(token.parent, sample)
     other_token = Token("zzz", original="bleh")
     sample.append(other_token)
     self.assertIn(other_token, sample)
     self.assertEqual(other_token.parent, sample)
     self.assertEqual(other_token.position, 1)
 def test_could_compare_a_stemme(self):
     token1 = Token("xxx", original="bla")
     token2 = Token("yyy", original="bla")
     token3 = Token("aaa", original="bleh")
     stemme1 = Stemm("zzz", text=None)
     stemme2 = Stemm("bbb", text=None)
     stemme1.occurrences.append(token1)
     stemme2.occurrences.append(token3)
     # We can only make the comparison with token before
     # See Token.__eq__ and Stemm.__eq__ for details
     self.assertTrue(token2 == stemme1)
     self.assertFalse(token2 == stemme2)
Пример #5
0
 def test_comma_is_not_strong_punctuation(self):
     token = Token("xxx", ",")
     self.assertFalse(token.is_strong_punctuation())
Пример #6
0
 def test_exclamation_point_is_strong_punctuation(self):
     token = Token("xxx", "!")
     self.assertTrue(token.is_strong_punctuation())
Пример #7
0
 def test_question_mark_is_strong_punctuation(self):
     token = Token("xxx", "?")
     self.assertTrue(token.is_strong_punctuation())
Пример #8
0
 def test_period_is_strong_punctuation(self):
     token = Token("xxx", ".")
     self.assertTrue(token.is_strong_punctuation())
 def test_comma_is_not_strong_punctuation(self):
     token = Token("xxx", ",")
     self.assertFalse(token.is_strong_punctuation())
 def test_exclamation_point_is_strong_punctuation(self):
     token = Token("xxx", "!")
     self.assertTrue(token.is_strong_punctuation())
 def test_question_mark_is_strong_punctuation(self):
     token = Token("xxx", "?")
     self.assertTrue(token.is_strong_punctuation())
 def test_period_is_strong_punctuation(self):
     token = Token("xxx", ".")
     self.assertTrue(token.is_strong_punctuation())
 def test_should_define_default_verified_lemme(self):
     token = Token("xxx", original="mot/SBC:sg")
     self.assertEqual(token.verified_tag, "SBC:sg")
     self.assertEqual(token.verified_lemme, "mot")
 def test_should_create_a_token(self):
     token = Token("mot", original="mot")
     self.assertTrue(isinstance(token, Token))
 def test_could_compare_with_string(self):
     token = Token("xxx", original="bla")
     self.assertTrue(token == "bla")
     self.assertTrue("bla" == token)
     self.assertFalse(token == "bleh")