本文整理汇总了Python中sppas.src.utils.makeunicode.u函数的典型用法代码示例。如果您正苦于以下问题:Python u函数的具体用法?Python u怎么用?Python u使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了u函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __milliers_ita
def __milliers_ita(self,number):
if number < 1000:
return self.centaine(number)
# Milliers
if number == 1000:
return u("mille")
if number > 1000 and number < 2000:
return u("mille-") + self.centaine(number % 1000)
if number >= 2000 and number < 10000:
if (number % 1000) != 0:
return self.unite(int(number/1000)).strip() + u("-mila-") + self.centaine(number % 1000)
return self.unite(int(number/1000)).strip() + u("-mila")
# Dizaines de milliers
if number == 10000:
return u("diecimila")
if number > 10000 and number < 100000:
if (number % 1000) != 0:
return self.dizaine(int(number/1000)).strip() + u("-mila-") + self.centaine(number % 1000)
return self.dizaine(int(number/1000)) + u("-mila")
# Centaines de milliers
if number == 100000:
return u("centomila")
if number >= 100000 and number < 1000000:
if (number % 1000) != 0:
return self.centaine(int(number/1000)).strip() + u("-mila-") + self.centaine(int(number%1000))
return self.centaine(int(number/1000)).strip() + u("mila-")
return str(number)
示例2: __milliers_fra
def __milliers_fra(self, number):
if number < 1000:
return self.centaine(number)
# Milliers
if number == 1000:
return u("mille ")
elif number > 1000 and number < 2000:
return u("mille-") + self.centaine(number % 1000)
elif number >= 2000 and number < 10000:
if (number % 1000) == 0:
return self.unite(int(number/1000)) + u("-mille-")
return self.unite(int(number/1000)) + u("-mille-") + self.centaine(number % 1000)
# Dizaines de milliers
if number == 10000:
return u("dix-mille")
elif number > 10000 and number < 100000:
if (number%1000) == 0:
return self.dizaine(int(number/1000)) + u("-mille ")
return self.dizaine(int(number/1000)) + u("-mille-") + self.centaine(number % 1000)
# Centaines de milliers
if number == 100000:
return u("cent-mille")
elif number >= 100000 and number < 1000000:
if (number % 1000) == 0:
return self.centaine(int(number/1000)) + u("-mille ")
return self.centaine(int(number/1000)) + u("-mille-") + self.centaine(int(number % 1000))
return str(number)
示例3: __parse_option
def __parse_option(items):
""" Parse an option.
Convert an "Option" section of the parser into an "Option" instance.
"""
oid = ""
otype = "str"
ovalue = ""
otext = ""
for name, value in items:
if name == "type":
otype = u(value)
elif name == "id":
oid = u(value)
elif name == "value":
ovalue = u(value)
elif name == "text":
otext = u(value)
opt = sppasOption(oid)
opt.set_type(otype)
opt.set_value(ovalue)
opt.set_text(otext)
return opt
示例4: __dizaine_cmn
def __dizaine_cmn(self, number):
if number < 10:
_str = self.unite(number)
elif 10 <= number < 100:
if (number%10) == 0:
_str = self.unite(int(number/10)) + u("十")
else:
_str = self.unite(int(number/10)) + u("十") + self.unite(number%10)
return _str
示例5: __milliards_spa
def __milliards_spa(self, number):
if number < 1000000000:
return self.millions(number)
n = number / 1000000000
r = number % 1000000000
s = u("%s-mil-millones") % self.millions(n)
if r == 0:
return s
else:
return u("%s-%s") % (s, self.millions(r))
示例6: test_all
def test_all(self):
l = sppasVocabulary(VOCAB, nodump=True)
self.assertEqual(len(l), 20)
self.assertTrue(l.is_unk('toto'))
self.assertFalse(l.is_unk('normale'))
self.assertFalse(l.is_unk("isn't"))
self.assertFalse(l.is_unk(u("đ")))
l.add("être")
self.assertTrue(l.is_in(u("être")))
self.assertTrue(u("être") in l)
示例7: pop_metainfo
def pop_metainfo(self, key):
""" Pop a meta information or raise a MetaKeyError exception.
:param key: (str) The key of the meta-information
"""
if u(key) not in self._metainfo.keys():
raise MetaKeyError(key)
del self._metainfo[u(key)]
示例8: __centaine_ita
def __centaine_ita(self, number):
if number < 100:
return self.dizaine(number)
if number == 100:
return u("cento")
if number > 100 and number <= 199:
return u("cento-") + self.dizaine(number%100)
if (number%100) == 0:
return " " + self.unite(number % 100) + u("-cento")
return " " + self.unite(int(number/100)) + u("-cento-") + self.dizaine(number % 100)
示例9: is_enable_metainfo
def is_enable_metainfo(self, key):
""" Return the status of a given key or raise a MetaKeyError exception.
:param key: (str) The key of the meta-information
"""
if u(key) not in self._metainfo:
raise MetaKeyError(key)
return self._metainfo[u(key)][0]
示例10: get_metainfo
def get_metainfo(self, key):
""" Return the value of a given key or raise a MetaKeyError exception.
:param key: (str) The key of the meta-information
"""
if u(key) not in self._metainfo:
raise MetaKeyError(key)
return self._metainfo[u(key)][1]
示例11: test_toe
def test_toe(self):
t = sppasTranscription()
s = t.clean_toe(u(" /l-e-f-o~-n/ "))
s = t.toe_spelling(s)
self.assertEqual(s, u('/l-e-f-o~-n/'))
s = t.clean_toe(u(" /le mot/ "))
s = t.toe_spelling(s)
self.assertEqual(s, u('/ le mot /'))
示例12: __millions_ita
def __millions_ita(self,number):
if number < 1000000:
return self.milliers(number)
if number >= 1000000 and number < 2000000:
return u("un-milione-") + self.milliers(int(number % 1000000))
if number >= 2000000 and number < 1000000000:
return self.centaine(int(number/1000000)).strip() + u("-milioni-") + self.milliers(int(number % 1000000))
return str(number)
示例13: __milliers_eng
def __milliers_eng(self, number):
if number < 1000:
return self.centaine(number)
n = number / 1000
r = number % 1000
s = u("%s thousand") % self.centaine(n)
if r == 0:
return s
else:
return u("%s %s") % (s, self.centaine(r))
示例14: __millions_pol
def __millions_pol(self, number):
if number < 1000000:
return self.milliers(number)
if number >= 1000000 and number < 2000000:
return u("milion ") + self.milliers(int(number % 1000000))
if number >= 2000000 and number < 1000000000:
return self.centaine(int(number/1000000)).strip() + u(" miliony ") + self.milliers(int(number % 1000000))
return str(number)
示例15: __milliards_eng
def __milliards_eng(self, number):
if number < 1000000000:
return self.millions(number)
n = number / 1000000000
r = number % 1000000000
s = u("%s billion") % self.centaine(n)
if r == 0:
return s
else:
return u("%s %s") % (s, self.millions(r))