Beispiel #1
0
    def test_collection_words_duplicate(self):
        collection = NormalCollection()
        self.assertIsNotNone(collection)

        collection.add_to_lookup(" don't", "do not")
        collection.add_to_lookup(" don't", "donot")

        self.assertEqual("he do not it",
                         collection.normalise_string(None, "he don't it"))
Beispiel #2
0
    def test_collection_string_duplicate(self):
        collection = NormalCollection()
        self.assertIsNotNone(collection)

        collection.add_to_lookup(".com", 'dot com')
        collection.add_to_lookup(".com", "dot co")

        self.assertEqual(
            "keithsterling dot com",
            collection.normalise_string(None, "keithsterling.com"))
Beispiel #3
0
    def test_collection_duplicate_jp(self):
        collection = NormalCollection()
        self.assertIsNotNone(collection)

        collection.add_to_lookup("①", '丸1')
        collection.add_to_lookup("①", '丸2')

        tokenizer = TokenizerJP()
        self.assertEqual("丸1の回答",
                         collection.normalise_string(tokenizer, "①の回答"))
    def test_collection_operations(self):
        collection = NormalCollection()
        self.assertIsNotNone(collection)

        collection.add_to_lookup(".COM", [re.compile('(^\\.COM|\\.COM|\\.COM$)', re.IGNORECASE), ' DOT COM '])

        self.assertTrue(collection.has_key(".COM"))
        self.assertEqual([re.compile('(^\\.COM|\\.COM|\\.COM$)', re.IGNORECASE), ' DOT COM '], collection.value(".COM"))

        self.assertEqual("keithsterling dot com", collection.normalise_string("keithsterling.COM"))
Beispiel #5
0
    def test_collection_operations_JP(self):
        collection = NormalCollection()
        self.assertIsNotNone(collection)

        collection.add_to_lookup("①", '丸1')
        tokenizer = TokenizerJP()

        self.assertTrue(collection.has_keyVal("①"))
        self.assertEqual('丸1', collection.value("①"))

        self.assertEqual("丸1の回答",
                         collection.normalise_string(tokenizer, "①の回答"))
Beispiel #6
0
    def test_collection_words_invalid(self):
        collection = NormalCollection()
        self.assertIsNotNone(collection)

        collection.add_to_lookup(" do not", "do not")

        self.assertFalse(collection.has_keyVal("dont"))
        self.assertIsNone(collection.value("dont"))

        self.assertIsNone(collection.normalise("dont"))
        self.assertEqual("he do nt it",
                         collection.normalise_string(None, "he do nt it"))
Beispiel #7
0
    def test_collection_string_invalid(self):
        collection = NormalCollection()
        self.assertIsNotNone(collection)

        collection.add_to_lookup(".com", 'dot com')

        self.assertFalse(collection.has_replace_key(".cox"))
        self.assertIsNone(collection.replace_value(".cox"))

        self.assertIsNone(collection.normalise(".cox"))
        self.assertEqual(
            "keithsterling dot com",
            collection.normalise_string(None, "keithsterling.com"))
Beispiel #8
0
    def test_collection_invalid_jp(self):
        collection = NormalCollection()
        self.assertIsNotNone(collection)

        collection.add_to_lookup("彼岸", 'お彼岸')

        self.assertFalse(collection.has_keyVal("彼氏"))
        self.assertIsNone(collection.value("彼氏"))

        tokenizer = TokenizerJP()
        self.assertIsNone(collection.normalise("彼氏"))
        self.assertEqual("彼氏の回答",
                         collection.normalise_string(tokenizer, "彼氏の回答"))