本文整理汇总了Python中CharniakParser.asNBestList方法的典型用法代码示例。如果您正苦于以下问题:Python CharniakParser.asNBestList方法的具体用法?Python CharniakParser.asNBestList怎么用?Python CharniakParser.asNBestList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CharniakParser
的用法示例。
在下文中一共展示了CharniakParser.asNBestList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __str__
# 需要导入模块: import CharniakParser [as 别名]
# 或者: from CharniakParser import asNBestList [as 别名]
def __str__(self):
"""Represent the n-best list in a similar output format to the
command-line parser and reranker."""
if self._reranked:
from cStringIO import StringIO
combined = StringIO()
combined .write('%d dummy\n' % len(self.parses))
for parse in self.parses:
combined.write('%s %s\n%s\n' % \
(parse.reranker_score, parse.parser_score, parse.ptb_parse))
combined.seek(0)
return combined.read()
else:
return parser.asNBestList(self._parses)
示例2: __str__
# 需要导入模块: import CharniakParser [as 别名]
# 或者: from CharniakParser import asNBestList [as 别名]
def __str__(self):
"""Represent the n-best list in a similar output format to the
command-line parser and reranker."""
sentence_id = self.sentence_id or 'x'
if self._reranked:
from cStringIO import StringIO
combined = StringIO()
combined.write('%d %s\n' % (len(self.parses), sentence_id))
for parse in self.parses:
combined.write('%s %s\n%s\n' % (parse.reranker_score,
parse.parser_score,
parse.ptb_parse))
combined.seek(0)
return combined.read()
else:
if self._parses:
return parser.asNBestList(self._parses, str(sentence_id))
else:
return '0 %s' % sentence_id