Beispiel #1
0
    def test_get(self):
        self.assertEqual(pinyin.get('你好'), 'nihao')
        self.assertEqual(pinyin.get(u('你好')), 'nihao')
        self.assertEqual(pinyin.get('你好吗?'), 'nihaoma?')
        self.assertEqual(pinyin.get('你好吗?'), u('nihaoma?'))

        self.assertEqual(pinyin.get('你好'), 'nihao')
        self.assertEqual(pinyin.get('叶'), 'ye')
Beispiel #2
0
    def test_get(self):
        self.assertEqual(pinyin.get('你好'), 'nihao')
        self.assertEqual(pinyin.get(u('你好')), 'nihao')
        self.assertEqual(pinyin.get('你好吗?'), 'nihaoma?')
        self.assertEqual(pinyin.get('你好吗?'), u('nihaoma?'))

        self.assertEqual(pinyin.get('你好'), 'nihao')
        self.assertEqual(pinyin.get('叶'), 'ye')
Beispiel #3
0
    def test_get(self):
        self.assertEqual(pinyin.get('你好'),
                         pinyin.get('你好', format="diacritical"))
        self.assertEqual(pinyin.get(u('你好'), format="strip"), u('nihao'))
        self.assertEqual(pinyin.get(u('你好'), format="numerical"), u('ni3hao3'))
        self.assertEqual(pinyin.get(u('你好'), format="diacritical"), u('nǐhǎo'))
        self.assertEqual(pinyin.get('你好吗?'), u('nǐhǎoma?'))
        self.assertEqual(pinyin.get('你好吗?'), u('nǐhǎoma?'))

        self.assertEqual(pinyin.get('你好'), u('nǐhǎo'))
        self.assertEqual(pinyin.get('叶'), u('yè'))
Beispiel #4
0
    def test_get(self):
        self.assertEqual(pinyin.get('你好'),
                         pinyin.get('你好', format="diacritical"))
        self.assertEqual(pinyin.get(u('你好'), format="strip"), u('nihao'))
        self.assertEqual(pinyin.get(u('你好'), format="numerical"), u('ni3hao3'))
        self.assertEqual(pinyin.get(u('你好'), format="diacritical"), u('nǐhǎo'))
        self.assertEqual(pinyin.get('你好吗?'), u('nǐhǎoma?'))
        self.assertEqual(pinyin.get('你好吗?'), u('nǐhǎoma?'))

        self.assertEqual(pinyin.get('你好'), u('nǐhǎo'))
        self.assertEqual(pinyin.get('叶'), u('yè'))
Beispiel #5
0
def pinyin():
    parser = argparse.ArgumentParser()
    parser.add_argument("chars", help="Input chinese words")
    args = parser.parse_args()

    if not args.chars:
        parser.print_help()
        return

    print(get(u(args.chars)))
Beispiel #6
0
 def test_correct_diacritical(self):
     self.assertEqual(pinyin.get("操"), u("cāo"))
     self.assertEqual(pinyin.get("小"), u("xiǎo"))
     self.assertEqual(pinyin.get("绝"), u("jué"))
     self.assertEqual(pinyin.get("被"), u("bèi"))
     self.assertEqual(pinyin.get("略"), u("lvè"))
Beispiel #7
0
 def test_mixed_chinese_english_input(self):
     self.assertEqual(pinyin.get('hi你好'), u('hinǐhǎo'))
Beispiel #8
0
    def test_get_initial(self):
        self.assertEqual(pinyin.get_initial('你好'), u('n h'))
        self.assertEqual(pinyin.get_initial('你好吗?'), u('n h m ?'))
        self.assertEqual(pinyin.get_initial('你好吗?'), u('n h m ?'))

        self.assertEqual(pinyin.get_initial('你好'), 'n h')
Beispiel #9
0
 def test_get_initial_with_delimiter(self):
     self.assertEqual(pinyin.get_initial('你好', "-"), u('n-h'))
     self.assertEqual(pinyin.get_initial('你好吗?', "-"), u('n-h-m-?'))
     self.assertEqual(pinyin.get_initial('你好吗?', "-"), u('n-h-m-?'))
Beispiel #10
0
 def test_get_with_delimiter(self):
     self.assertEqual(pinyin.get('你好', " "), u('nǐ hǎo'))
     self.assertEqual(pinyin.get('你好吗?', " "), u('nǐ hǎo ma ?'))
     self.assertEqual(pinyin.get('你好吗?', " "), u('nǐ hǎo ma ?'))
Beispiel #11
0
 def test_correct_diacritical(self):
     self.assertEqual(pinyin.get("操"), u("cāo"))
     self.assertEqual(pinyin.get("小"), u("xiǎo"))
     self.assertEqual(pinyin.get("绝"), u("jué"))
     self.assertEqual(pinyin.get("被"), u("bèi"))
Beispiel #12
0
 def test_mixed_chinese_english_input(self):
     self.assertEqual(pinyin.get('hi你好'), u('hinǐhǎo'))
Beispiel #13
0
    def test_get_initial(self):
        self.assertEqual(pinyin.get_initial('你好'), u('n h'))
        self.assertEqual(pinyin.get_initial('你好吗?'), u('n h m ?'))
        self.assertEqual(pinyin.get_initial('你好吗?'), u('n h m ?'))

        self.assertEqual(pinyin.get_initial('你好'), 'n h')
Beispiel #14
0
 def test_get_initial_with_delimiter(self):
     self.assertEqual(pinyin.get_initial('你好', "-"), u('n-h'))
     self.assertEqual(pinyin.get_initial('你好吗?', "-"), u('n-h-m-?'))
     self.assertEqual(pinyin.get_initial('你好吗?', "-"), u('n-h-m-?'))
Beispiel #15
0
 def test_get_with_delimiter(self):
     self.assertEqual(pinyin.get('你好', " "), u('nǐ hǎo'))
     self.assertEqual(pinyin.get('你好吗?', " "), u('nǐ hǎo ma ?'))
     self.assertEqual(pinyin.get('你好吗?', " "), u('nǐ hǎo ma ?'))