本文整理匯總了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