def test_punctuation(self):
     self.assertEqual(
         transcribe(['没有', ',', '没有', '。'], 'Pinyin'),
         ['méi yǒu', ',', 'méi yǒu', '.'],
     )
     self.assertEqual(
         transcribe(['没有', '。', '没有', '。'], 'Pinyin'),
         ['méi yǒu', '.', 'méi yǒu', '.'],
     )
Ejemplo n.º 2
0
 def test_multiple_words_single(self):
     self.assertEqual(transcribe('中国', 'Pinyin'), ['zhōng guó'])
Ejemplo n.º 3
0
 def test_bopomofo(self):
     self.assertEqual(transcribe(['你'], 'Bopomofo'), ['ㄋㄧˇ'])
Ejemplo n.º 4
0
 def test_some_chinese(self):
     self.assertEqual(transcribe(['foo', '你'], 'Pinyin'), ['nǐ'])
Ejemplo n.º 5
0
 def test_no_chinese(self):
     self.assertEqual(transcribe(['foo'], 'Pinyin'), [])
Ejemplo n.º 6
0
 def test_multiple_words(self):
     self.assertEqual(transcribe(['图书', '馆'], 'Pinyin'), ['tú shū', 'guǎn'])
Ejemplo n.º 7
0
 def test_single_word(self):
     self.assertEqual(transcribe(['你'], 'Pinyin'), ['nǐ'])
 def test_punctuation_irrelevant(self):
     self.assertEqual(
         transcribe(['我要喝湯'])[0] + ' !',
         transcribe(['我要喝湯!'])[0])
 def test_ungrouped_chars(self):
     self.assertEqual(transcribe(['你什么时候能来?']),
                      ['nǐ shén me shí hou néng lái ?'])
     self.assertEqual(transcribe(['我要喝湯!']), ['wǒ yào hē tāng !'])
 def test_grouped_chars(self):
     self.assertEqual(
         transcribe(['你', '什么', '时候', '能', '来', '?']),
         ['nǐ', 'shén me', 'shí hou', 'néng', 'lái', '?'],
     )
 def test_punctuation_retained_converted(self):
     self.assertEqual(
         transcribe(['没有', ',', '没有', '。'], 'Pinyin'),
         ['méi yǒu', ',', 'méi yǒu', '.'],
     )
 def test_mixed_english_chinese(self):
     self.assertEqual(transcribe(['foo', '你'], 'Pinyin'), ['foo', 'nǐ'])
     self.assertEqual(transcribe(['Brian的'], 'Pinyin'), ['Brian de'])
 def test_split_sentence(self):
     self.assertEqual(transcribe(['没有。'], 'Pinyin'), ['méi', 'yǒu', '.'])
 def test_jyutping_sentence(self):
     self.assertEqual(
         transcribe(['對唔住', ',', '我', '唔係', '李', '太'], 'jyutping', 'trad'),
         ['deoi3 m4 zyu6', ',', None, 'm4 hai6', 'lei5', 'taai3'],
     )
 def test_jyutping_words(self):
     self.assertEqual(transcribe(['上海'], 'jyutping', 'trad'), [None])
     self.assertEqual(transcribe(['上海人'], 'jyutping', 'trad'),
                      ['soeng6 hoi2 jan4'])