Exemplo n.º 1
0
 def test_ascii_pinyin(self):
     "Test simple conversion from ascii to unicode pinyin."
     s = pinyin_table.get_pinyin_table()
     self.assertEqual(u'bāolíqǔan', s.from_ascii('bao1li2 quan3'))
     self.assertEqual(u'chéngzhewéiwáng',
                      s.from_ascii('cheng2zhewei2wang2'))
     self.assertEqual(u'lǖ', s.from_ascii(u'lü1'))
     return
Exemplo n.º 2
0
    def test_strip_tones(self):
        table = pinyin_table.get_pinyin_table()

        # Standard cases
        self.assertEqual(table.strip_tones('xia4wu3hao3'), 'xiawuhao')
        self.assertEqual(table.strip_tones('xia4bu4lai2tai2'), 'xiabulaitai')

        # Uppercase
        self.assertEqual(table.strip_tones('Xia4bu4Lai2tai2'), 'xiabulaitai')

        # Presence of v
        self.assertEqual(table.strip_tones(u'yi1lü4'), u'yilü')
Exemplo n.º 3
0
 def test_pinyin_table(self):
     "Tests simple conversion from hanzi to unicode pinyin."
     table = pinyin_table.get_pinyin_table()
     self.assertEqual(table.from_hanzi(u'一代风流'), u'yīdàifēnglíu')
     return