本文整理匯總了Python中unihandecode.Unihandecoder.decode方法的典型用法代碼示例。如果您正苦於以下問題:Python Unihandecoder.decode方法的具體用法?Python Unihandecoder.decode怎麽用?Python Unihandecoder.decode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類unihandecode.Unihandecoder
的用法示例。
在下文中一共展示了Unihandecoder.decode方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_kana
# 需要導入模塊: from unihandecode import Unihandecoder [as 別名]
# 或者: from unihandecode.Unihandecoder import decode [as 別名]
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
示例2: test_combining_chars
# 需要導入模塊: from unihandecode import Unihandecoder [as 別名]
# 或者: from unihandecode.Unihandecoder import decode [as 別名]
def test_combining_chars(self):
TESTS = [
("\u0031\u20de", "1"),
]
u = Unihandecoder(lang="ja")
for input, output in TESTS:
self.failUnlessEqual(u.decode(input), output)
示例3: test_squared_chars
# 需要導入模塊: from unihandecode import Unihandecoder [as 別名]
# 或者: from unihandecode.Unihandecoder import decode [as 別名]
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)
示例4: test_long_japanese_text
# 需要導入模塊: from unihandecode import Unihandecoder [as 別名]
# 或者: from unihandecode.Unihandecoder import decode [as 別名]
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)
示例5: test_mathematical_digits
# 需要導入模塊: from unihandecode import Unihandecoder [as 別名]
# 或者: from unihandecode.Unihandecoder import decode [as 別名]
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)
示例6: test_mac_japanese_pua
# 需要導入模塊: from unihandecode import Unihandecoder [as 別名]
# 或者: from unihandecode.Unihandecoder import decode [as 別名]
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)
示例7: test_zh
# 需要導入模塊: from unihandecode import Unihandecoder [as 別名]
# 或者: from unihandecode.Unihandecoder import decode [as 別名]
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)
示例8: test_compatibility_composite
# 需要導入模塊: from unihandecode import Unihandecoder [as 別名]
# 或者: from unihandecode.Unihandecoder import decode [as 別名]
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)
示例9: test_combining_chars
# 需要導入模塊: from unihandecode import Unihandecoder [as 別名]
# 或者: from unihandecode.Unihandecoder import decode [as 別名]
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)
示例10: test_zh
# 需要導入模塊: from unihandecode import Unihandecoder [as 別名]
# 或者: from unihandecode.Unihandecoder import decode [as 別名]
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)
示例11: test_decomposed_form
# 需要導入模塊: from unihandecode import Unihandecoder [as 別名]
# 或者: from unihandecode.Unihandecoder import decode [as 別名]
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)
示例12: test_ja
# 需要導入模塊: from unihandecode import Unihandecoder [as 別名]
# 或者: from unihandecode.Unihandecoder import decode [as 別名]
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
# 需要導入模塊: from unihandecode import Unihandecoder [as 別名]
# 或者: from unihandecode.Unihandecoder import decode [as 別名]
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_decomposed_form
# 需要導入模塊: from unihandecode import Unihandecoder [as 別名]
# 或者: from unihandecode.Unihandecoder import decode [as 別名]
def test_decomposed_form(self):
TESTS = [
(u"\u0041\u0301", "A"), # "A" with accent mark
(u"\u0061\u0323\u0302", "a"), # "a" with accent marks
(u"\u30AB\u3099", "ga"), # "ガ" coded by decomposed from as ' カ゛ '
(u"\u304B\u3099", "ga"), # "が" coded by decomposed from as ' か゛ '
]
u = Unihandecoder(lang="ja")
for input, output in TESTS:
self.failUnlessEqual(u.decode(input), output)
示例15: test_kr
# 需要導入模塊: from unihandecode import Unihandecoder [as 別名]
# 或者: from unihandecode.Unihandecoder import decode [as 別名]
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)