Пример #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')
Пример #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')
Пример #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è'))
Пример #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è'))
Пример #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)))
Пример #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è"))
Пример #7
0
 def test_mixed_chinese_english_input(self):
     self.assertEqual(pinyin.get('hi你好'), u('hinǐhǎo'))
Пример #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')
Пример #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-?'))
Пример #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 ?'))
Пример #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"))
Пример #12
0
 def test_mixed_chinese_english_input(self):
     self.assertEqual(pinyin.get('hi你好'), u('hinǐhǎo'))
Пример #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')
Пример #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-?'))
Пример #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 ?'))