# -*- coding: utf-8 -*-
import unittest

from preprocessing.language_standardizer import zhi


class ZhiTest(unittest.TestCase):

    def test_translate(self):
        simplified = u'来自Bandai Namco Games TW/HK 官方FACEBOOK情报' \
                     u'，PS3/PSV平台动漫改编作品《刀剑神域：失落之歌》繁' \
                     u'体中文版正式公开!预定于2015年发售，并一同公开了繁' \
                     u'体中文版宣传片，下面来欣赏了解一下。'
        traditional = u'來自Bandai Namco Games TW/HK 官方FACEBOOK情報' \
                      u'，PS3/PSV平臺動漫改編作品《刀劍神域：失落之歌》繁' \
                      u'體中文版正式公開!預定於2015年發售，並一同公開了繁' \
                      u'體中文版宣傳片，下面來欣賞了解一下。'

        simp_is_simp = zhi.is_simplified(simplified)
        self.assertTrue(simp_is_simp)
        trad_is_trad = zhi.is_traditional(traditional)
        self.assertTrue(trad_is_trad)

        trans_traditional = zhi.make_traditional(simplified)
        self.assertEqual(trans_traditional, traditional)

    def test_strip(self):
        expected_result = u'hel lo          what s  yo1231薩達231 ur 盛大阿什頓name   '
        testing = u"hel，lo! &^*&^*(&what：s 《yo1231薩達231。ur 盛大阿什頓name? &"

        remove_result = zhi.strip(testing)
        self.assertEqual(remove_result, expected_result)
@@ -17,16 +17,43 @@
 f-8 -*-%0A
+from itertools import izip%0A
 import u
@@ -943,32 +943,104 @@
 st_strip(self):%0A
+        %22%22%22%0A        Test replacement of unwanted characters%0A        %22%22%22%0A
         expected
@@ -1277,8 +1277,562 @@
 _result)
+%0A%0A    def test_unicode_sub(self):%0A        %22%22%22%0A        Test unicode Z-variant substitution%0A        %22%22%22%0A        # TODO: test more characters with variants%0A        text = u'%E8%99%95%E9%83%A8%E6%AD%A2'%0A        desired = u'%E5%87%A6%E5%8D%A9%E5%8F%AA'%0A%0A        actual = zhi.chunk_gen(text)%0A        for actual_char, desired_char in izip(actual, desired):%0A            self.assertEqual(actual_char, desired_char)%0A%0A        # Now try the other way%0A        also_desired = zhi.chunk_gen(desired)%0A        for ad_char, desired_char in izip(also_desired, desired):%0A            self.assertEqual(ad_char, desired_char)

add unicode character reduction