本文整理汇总了Python中unihandecode.Unihandecoder类的典型用法代码示例。如果您正苦于以下问题:Python Unihandecoder类的具体用法?Python Unihandecoder怎么用?Python Unihandecoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Unihandecoder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_combining_chars
def test_combining_chars(self):
TESTS = [
("\u0031\u20de", "1"),
]
u = Unihandecoder(lang="ja")
for input, output in TESTS:
self.failUnlessEqual(u.decode(input), output)
示例2: test_squared_chars
def test_squared_chars(self):
TESTS = [
(u"\u3301", "alpha"), # combined Alpha in Katakana
(u"\u3302", "ampere"), # combined Ampere in Katakana
(u"\u3304", "inning"),
(u"\u3306", "won"), # combined Won in Katakana
(u"\u3307", "escudo"),
(u"\u3308", "acre"), # combined Acre in Katakana
(u"\u3309", "ounce"), # combined ounce in Katakana
(u"\u330a", "ohm"), # combined Ohm in Katakana
(u"\u3349", "milli"), # milli in Katakana
(u"\u3314", "kilo"), # kilo in Katakana
(u"\u3315", "kilogram"), # kilo gram in Katakana
(u"\u3316", "kilometer"), # kilo metre in Katakana
(u"\u3322", "centi"), # centi in Katakana
(u"\u334d", "meter"), #metre in Katakana
(u"\u3318", "gram"), # gram in Katakana
(u"\u3327", "ton"), # ton in Katakana
(u"\u3303", "are"), # are in Katakana
(u"\u3336", "hectare"), # hect-are in Katakana
(u"\u337f", "Inc."), # kabusiki kaisha in Katakana
]
u = Unihandecoder(lang="ja")
for input, output in TESTS:
self.failUnlessEqual(u.decode(input), output)
示例3: test_long_japanese_text
def test_long_japanese_text(self):
input = "日本国民は、正当に選挙された国会における代表者を通じて行動し、われらとわれらの子孫のために、諸国民との協和による成果と、わが国全土にわたつて自由のもたらす恵沢を確保し、政府の行為によつて再び戦争の惨禍が起ることのないやうにすることを決意し、ここに主権が国民に存することを宣言し、この憲法を確定する。そもそも国政は、国民の厳粛な信託によるものであつて、その権威は国民に由来し、その権力は国民の代表者がこれを行使し、その福利は国民がこれを享受する。これは人類普遍の原理であり、この憲法は、かかる原理に基くものである。われらは、これに反する一切の憲法、法令及び詔勅を排除する。"
output = "Nihonkokumin ha, Seitou ni Senkyo sareta Kokkai niokeru Daihyousha wo Tsuuji te Koudou shi, wareratowarerano Shison notameni, Shokokumin tono Kyouwa niyoru Seika to, waga Kuni Zendo niwatatsute Jiyuu nomotarasu Keitaku wo Kakuho shi, Seifu no Koui niyotsute Futatabi Sensou no Sanka ga Okoru kotononaiyaunisurukotowo Ketsui shi, kokoni Shuken ga Kokumin ni Sonsu rukotowo Sengen shi, kono Kenpou wo Kakuteisu ru. somosomo Kokusei ha, Kokumin no Genshuku na Shintaku niyorumonodeatsute, sono Ken'i ha Kokumin ni Yurai shi, sono Kenryoku ha Kokumin no Daihyousha gakorewo Koushi shi, sono Fukuri ha Kokumin gakorewo Kyouju suru. koreha Jinruifuhen no Genri deari, kono Kenpou ha, kakaru Genri ni Motozuku monodearu. wareraha, koreni Hansu ru Issai no Kenpou, Hourei Oyobi Shouchoku wo Haijo suru."
u = Unihandecoder(lang="ja")
self.assertEqual(u.decode(input), output)
示例4: test_zh
def test_zh(self):
ZHTESTS = [
('\u660e\u5929\u660e\u5929\u7684\u98ce\u5439',
'Ming Tian Ming Tian De Feng Chui ')
]
u = Unihandecoder(lang="zh")
for instr, output in ZHTESTS:
self.failUnlessEqual(u.decode(instr), output)
示例5: test_mac_japanese_pua
def test_mac_japanese_pua(self):
TESTS = [
("\uF862\u6709\u9650\u4F1A\u793E",
"Yuugengaisha"),
]
u = Unihandecoder(lang="ja")
for input, output in TESTS:
self.failUnlessEqual(u.decode(input), output)
示例6: test_compatibility_composite
def test_compatibility_composite(self):
TESTS = [
(u"\ufb01","fi"),
(u"\u0032\u2075", "25"),
]
u = Unihandecoder(lang="zh")
for input, output in TESTS:
self.failUnlessEqual(u.decode(input), output)
示例7: test_combining_chars
def test_combining_chars(self):
TESTS = [
# roman number "1" wrapped with solid square
(u"\u0031\u20de", "1"),
]
u = Unihandecoder(lang="ja")
for input, output in TESTS:
self.failUnlessEqual(u.decode(input), output)
示例8: test_mathematical_digits
def test_mathematical_digits(self):
# 5 consecutive sequences of 0-9
u = Unihandecoder()
for n in range(0x1d7ce, 0x1d800):
a = chr(ord('0') + (n-0x1d7ce) % 10)
b = u.decode(chr(n))
self.failUnlessEqual(b, a)
示例9: test_decomposed_form
def test_decomposed_form(self):
TESTS = [
("\u0041\u0301", "A"),
("\u0061\u0323\u0302", "a"),
("\u304B\u3099", "ga"),
]
u = Unihandecoder(lang="ja")
for input, output in TESTS:
self.failUnlessEqual(u.decode(input), output)
示例10: test_kana
def test_kana(self):
u = Unihandecoder(lang="ja")
for n in xrange(0x3000,0x30ff):
# Just check that it doesn't throw an exception
try:
t = unichr(n)
u.decode(t)
except:
print "catch error at %02x"%n
示例11: test_zh
def test_zh(self):
ZHTESTS = [
(u"\u660e\u5929\u660e\u5929\u7684\u98ce\u5439",
'Ming Tian Ming Tian De Feng Chui '),
(u"馮", "Feng "),
]
u = Unihandecoder(lang="zh")
for input, output in ZHTESTS:
self.failUnlessEqual(u.decode(input), output)
示例12: test_ja
def test_ja(self):
JATESTS = [
('\u660e\u65e5\u306f\u660e\u65e5\u306e\u98a8\u304c\u5439\u304f',
'Ashita ha Ashita no Kaze ga Fuku'),
("\u660e\u5929\u660e\u5929\u7684\u98ce\u5439",
'Mei Tenmei Ten Teki Sui')
]
u = Unihandecoder(lang="ja")
for instr, output in JATESTS:
self.failUnlessEqual(u.decode(instr), output)
示例13: test_vn
def test_vn(self):
VNTESTS = [
(u'Ng\xe0y mai gi\xf3 th\u1ed5i v\xe0o ng\xe0y mai',
'Ngay mai gio thoi vao ngay mai'),
(u"\u660e\u5929\u660e\u5929\u7684\u98ce\u5439",
'Minh Tian Minh Tian De Feng Xuy ')
]
u = Unihandecoder(lang="vn")
for input, output in VNTESTS:
self.failUnlessEqual(u.decode(input), output)
示例14: test_zh
def test_zh(self):
ZHTESTS = [
("\u3400", 'Qiu '),
("\u660e\u5929\u660e\u5929\u7684\u98ce\u5439",
'Ming Tian Ming Tian De Feng Chui '),
("馮", "Feng "),
]
u = Unihandecoder(lang="zh")
for input, output in ZHTESTS:
self.assertEqual(u.decode(input), output)
示例15: test_kr
def test_kr(self):
KRTESTS = [
(u'\ub0b4\uc77c\uc740 \ub0b4\uc77c \ubc14\ub78c\uc774 \ubd84\ub2e4',
'naeileun naeil barami bunda'),
(u"\u660e\u5929\u660e\u5929\u7684\u98ce\u5439",
'Myeng Chen Myeng Chen Cek Feng Chwi ')
]
u = Unihandecoder(lang="kr")
for input, output in KRTESTS:
self.failUnlessEqual(u.decode(input), output)