本文整理汇总了Python中texttable.Texttable.set_asmarkdown方法的典型用法代码示例。如果您正苦于以下问题:Python Texttable.set_asmarkdown方法的具体用法?Python Texttable.set_asmarkdown怎么用?Python Texttable.set_asmarkdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类texttable.Texttable
的用法示例。
在下文中一共展示了Texttable.set_asmarkdown方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: eval_dir
# 需要导入模块: from texttable import Texttable [as 别名]
# 或者: from texttable.Texttable import set_asmarkdown [as 别名]
def eval_dir(path, markdown=False, dprefix=False,
evalmethod=None, numlabel=False):
""" Evaluate the results in the dir by MRR
Argument:
dirname -- the path to the diretory containing evaluation results
"""
if evalmethod is None:
ef = mrr
else:
ef = globals()[evalmethod]
files = sorted(os.listdir(path))
names = sorted(set([n.rsplit('.', 1)[0][3:] for n in files
if n.endswith('.res')]),
key=lambda item: (len(item), item))
if dprefix:
prefices = sorted(set([n[:2] for n in files]))
else:
prefices = PREFICES
table = Texttable(max_width=0)
if markdown:
table.set_asmarkdown()
else:
table.set_deco(0)
table.set_cols_dtype(['t'] + ['f'] * len(prefices))
table.set_cols_align(['l'] + ['r'] * len(prefices))
table.set_precision(4)
table.add_rows([['', ] + prefices])
for n in names:
scores = list()
for prefix in prefices:
try:
eva = NP.array([v for v in iterrank(
os.path.join(path, '%s_%s.res' % (prefix, n)))],
dtype=NP.float64)
scores.append(ef(eva))
except IOError:
scores.append('N/A')
if numlabel:
n = ' '.join([m.group() for m in NUMBER.finditer(n)])
table.add_row([n, ] + scores)
print table.draw()