本文整理汇总了Python中nltk.compat.python_2_unicode_compatible方法的典型用法代码示例。如果您正苦于以下问题:Python compat.python_2_unicode_compatible方法的具体用法?Python compat.python_2_unicode_compatible怎么用?Python compat.python_2_unicode_compatible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nltk.compat
的用法示例。
在下文中一共展示了compat.python_2_unicode_compatible方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _str
# 需要导入模块: from nltk import compat [as 别名]
# 或者: from nltk.compat import python_2_unicode_compatible [as 别名]
def _str(self):
outstr = ""
if not '_type' in self:
outstr = _pretty_any(self)
elif self['_type'] == 'frame':
outstr = _pretty_frame(self)
elif self['_type'] == 'fe':
outstr = _pretty_fe(self)
elif self['_type'] == 'lu':
outstr = _pretty_lu(self)
elif self['_type'] == 'semtype':
outstr = _pretty_semtype(self)
elif self['_type'] == 'framerelationtype':
outstr = _pretty_frame_relation_type(self)
elif self['_type'] == 'framerelation':
outstr = _pretty_frame_relation(self)
elif self['_type'] == 'ferelation':
outstr = _pretty_fe_relation(self)
else:
outstr = _pretty_any(self)
# ensure result is unicode string prior to applying the
# @python_2_unicode_compatible decorator (because non-ASCII characters
# could in principle occur in the data and would trigger an encoding error when
# passed as arguments to str.format()).
# assert isinstance(outstr, unicode) # not in Python 3.2
return outstr
示例2: _str
# 需要导入模块: from nltk import compat [as 别名]
# 或者: from nltk.compat import python_2_unicode_compatible [as 别名]
def _str(self):
outstr = ""
if not '_type' in self:
outstr = _pretty_any(self)
elif self['_type'] == 'frame':
outstr = _pretty_frame(self)
elif self['_type'] == 'fe':
outstr = _pretty_fe(self)
elif self['_type'] == 'lu':
outstr = _pretty_lu(self)
elif self['_type'] == 'luexemplars': # list of ALL exemplars for LU
outstr = _pretty_exemplars(self, self[0].LU)
elif self['_type'] == 'fulltext_annotation': # list of all sentences for full-text doc
outstr = _pretty_fulltext_sentences(self)
elif self['_type'] == 'lusentence':
outstr = _pretty_annotation(self)
elif self['_type'] == 'fulltext_sentence':
outstr = _pretty_fulltext_sentence(self)
elif self['_type'] in ('luannotationset', 'fulltext_annotationset'):
outstr = _pretty_annotation(self, aset_level=True)
elif self['_type'] == 'posannotationset':
outstr = _pretty_pos(self)
elif self['_type'] == 'semtype':
outstr = _pretty_semtype(self)
elif self['_type'] == 'framerelationtype':
outstr = _pretty_frame_relation_type(self)
elif self['_type'] == 'framerelation':
outstr = _pretty_frame_relation(self)
elif self['_type'] == 'ferelation':
outstr = _pretty_fe_relation(self)
else:
outstr = _pretty_any(self)
# ensure result is unicode string prior to applying the
# @python_2_unicode_compatible decorator (because non-ASCII characters
# could in principle occur in the data and would trigger an encoding error when
# passed as arguments to str.format()).
# assert isinstance(outstr, unicode) # not in Python 3.2
return outstr