本文整理汇总了Python中UI.render_info方法的典型用法代码示例。如果您正苦于以下问题:Python UI.render_info方法的具体用法?Python UI.render_info怎么用?Python UI.render_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UI
的用法示例。
在下文中一共展示了UI.render_info方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print_blocks_for_selected_meaning
# 需要导入模块: import UI [as 别名]
# 或者: from UI import render_info [as 别名]
def print_blocks_for_selected_meaning(self):
""" This methods prints the block strings for the selected meaning.
Example:
--------
For the word '안녕', the blocks will be ['안', '녕']
"""
UI.render_info('print blocks for selected meaning')
UI.render_info([block.get_str() for block in self.blocks[self.selected_meaning]])
return [block.get_str() for block in self.blocks[self.selected_meaning]]
示例2: compute_blocks
# 需要导入模块: import UI [as 别名]
# 或者: from UI import render_info [as 别名]
def compute_blocks(self, compute_ethym=False):
""" Compute the blocks given the input string.
Output:
Returns a list of lists of blocks, i.e.
[ [b11, ..., b1n1], [b21, ..., b2n2], ...], where each list of
blocks [bi1, ..., bini] corresponds to a possible meaning of the
input string.
Note:
In this CSV dictionnary based implemenation, only one meaning is
available.
"""
if DEBUG:
UI.render_info('compute_blocks() called for word ' + self.string)
suffixes = {'하다':'하다 verb particule', \
'합니다': 'formal 하다 ending', \
'하세요': 'formal imperative form of 하다', \
'요': 'politeness particle'}
detected_suffix = ''
# for suffix in suffixes.keys():
# if self.string.endswith(suffix):
# detected_suffix = suffix
# continue
body = self.string[0:len(self.string)-len(detected_suffix)]
#if not compute_ethym:
#blocks = [Block(body[i]) for i in range(len(body)) if body[i] != ' ']
blocks = compute_blocks_re(body)
# else:
# hanja = get_hanja(body)
# if DEBUG:
# UI.render_info(hanja)
# blocks = [Block(body[i], ethym=hanja[i]) for i in range(len(body)) if body[i] != ' ']
# if detected_suffix:
# suffix_desc = 'Suffix: ' + suffixes[detected_suffix]
# blocks.append(Block(detected_suffix, ethym=suffix_desc))
if DEBUG:
for block in blocks:
UI.render_info(block.get_string())
return [blocks]
示例3: compute_blocks
# 需要导入模块: import UI [as 别名]
# 或者: from UI import render_info [as 别名]
def compute_blocks(self, compute_ethym=False):
""" Compute the blocks given the input string.
Output:
Returns a list of lists of blocks, i.e.
[ [b11, ..., b1n1], [b21, ..., b2n2], ...], where each list of
blocks [bi1, ..., bini] corresponds to a possible meaning of the
input string.
Note:
In this CSV dictionnary based implemenation, only one meaning is
available.
"""
if DEBUG:
UI.render_info('compute_blocks() called for word ' + self.string)
suffixes = {u'하다':u'하다 verb particule', \
u'합니다': u'formal 하다 ending', \
u'하세요': u'formal imperative form of 하다', \
u'요': u'politeness particle'}
detected_suffix = ''
for suffix in suffixes.keys():
if self.string.endswith(suffix):
detected_suffix = suffix
continue
body = self.string[0:len(self.string)-len(detected_suffix)]
if not compute_ethym:
blocks = [Block(body[i]) for i in range(len(body)) if body[i] != ' ']
else:
ethym = get_hanja(body)
if DEBUG:
UI.render_info(ethym)
blocks = [Block(body[i], ethym=ethym[i], \
meaning=get_hanja_meaning(ethym[i])) \
for i in range(len(body)) if body[i] != ' ']
if detected_suffix:
suffix_desc = 'Suffix: ' + suffixes[detected_suffix]
blocks.append(Block(detected_suffix, meaning=suffix_desc))
return [blocks]
示例4: tuple
# 需要导入模块: import UI [as 别名]
# 或者: from UI import render_info [as 别名]
_uu8 = lambda *tt: tuple(_u8(t) for t in tt)
DEBUG = True
#==============================================================================
# AWA MAIN
#==============================================================================
#UI.render_empty()
# Entree
UI.render_top()
if DEBUG:
UI.render_info('Python version ' + str(sys.version_info.major))
# Main
form = cgi.FieldStorage()
if 'word' in form.keys():
input_str = form["word"].value
language = detect_language(_u(input_str))
if DEBUG:
UI.render_info(language)
if language == 'korean':
from Korean import get_words_with_block
from Korean import KoreanWord as Word
elif language == 'thai':