本文整理汇总了Python中nltk.internals.overridden函数的典型用法代码示例。如果您正苦于以下问题:Python overridden函数的具体用法?Python overridden怎么用?Python overridden使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了overridden函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse
def parse(self, sent, *args, **kwargs):
'''
:param sent: list(str)
:param args:
:param kwargs:
:return:An iterator that generates parse for the sentence.
'''
if overridden(self.parse_sents):
return next(self.parse_sents([sent], *args, **kwargs))
elif overridden(self.parse_one):
return (tree for tree in [self.parse_one(sent, *args, **kwargs)] if tree is not None)
elif overridden(self.parse_all):
return iter(self.parse_all(sent, *args, **kwargs))
else:
raise NotImplementedError()
示例2: tokenize
def tokenize(self, s):
"""
Return a tokenized copy of *s*.
:rtype: list of str
"""
if overridden(self.tokenize_sents):
return self.tokenize_sents([s])[0]
示例3: parse
def parse(self, sent, *args, **kwargs):
"""
:return: An iterator that generates parse trees for the sentence.
When possible this list is sorted from most likely to least likely.
:param sent: The sentence to be parsed
:type sent: list(str)
:rtype: iter(Tree)
"""
if overridden(self.parse_sents):
return next(self.parse_sents([sent], *args, **kwargs))
elif overridden(self.parse_one):
return (tree for tree in [self.parse_one(sent, *args, **kwargs)] if tree is not None)
elif overridden(self.parse_all):
return iter(self.parse_all(sent, *args, **kwargs))
else:
raise NotImplementedError()
示例4: classify
def classify(self, featureset):
"""
@return: the most appropriate label for the given featureset.
@rtype: label
"""
if overridden(self.batch_classify):
return self.batch_classify([featureset])[0]
else:
raise NotImplementedError()
示例5: classify
def classify(self, featureset):
"""
:return: the most appropriate set of labels for the given featureset.
:rtype: set(label)
"""
if overridden(self.classify_many):
return self.classify_many([featureset])[0]
else:
raise NotImplementedError()
示例6: prob_classify
def prob_classify(self, featureset):
"""
:return: a probability distribution over labels for the given
featureset.
:rtype: ProbDistI
"""
if overridden(self.prob_classify_many):
return self.prob_classify_many([featureset])[0]
else:
raise NotImplementedError()
示例7: tag
def tag(self, tokens):
"""
Determine the most appropriate tag sequence for the given
token sequence, and return a corresponding list of tagged
tokens. A tagged token is encoded as a tuple ``(token, tag)``.
:rtype: list(tuple(str, str))
"""
if overridden(self.tag_sents):
return self.tag_sents([tokens])[0]
示例8: tag
def tag(self, tokens):
'''
标注单个句子
:param tokens:list
:return:list(tuple(str,str))
'''
if overridden(self.tag_sents):
return self.tag_sents([tokens])[0]
else:
raise NotImplementedError()
示例9: prob_classify
def prob_classify(self, featureset):
"""
@return: a probability distribution over labels for the given
featureset.
@rtype: L{ProbDistI <nltk.probability.ProbDistI>}
"""
if overridden(self.batch_prob_classify):
return self.batch_prob_classify([featureset])[0]
else:
raise NotImplementedError()
示例10: tokenize
def tokenize(self, s):
"""
Return a tokenized copy of *s*.
:rtype: list of str
"""
if overridden(self.batch_tokenize):
return self.batch_tokenize([s])[0]
else:
raise NotImplementedError()
示例11: tokenize
def tokenize(self, s):
"""
Divide the given string into a list of substrings.
@return: C{list} of C{str}
"""
if overridden(self.batch_tokenize):
return self.batch_tokenize([s])[0]
else:
raise NotImplementedError()
示例12: parse
def parse(self, sent, *args, **kwargs):
'''
解析单个句子
:param tokens:list
:return:list(tuple(str,str))
'''
if overridden(self.parse_sents):
return self.parse_sents([sent])[0]
else:
raise NotImplementedError()
示例13: tag
def tag(self, tokens):
'''
Determine the most appropriate tag sequence for the given token sequence,
and return a corresponding list of tagged tokens
:param tokens: list of tokens ['我','爱','北京','天安门']
:return: list(tuple(str,str)
'''
if overridden(self.tag_sents):
return self.tag_sents([tokens])[0]
else:
raise NotImplementedError()
示例14: iter_parse
def iter_parse(self, sent):
"""
:return: An iterator that generates parse trees that represent
possible structures for the given sentence. When possible,
this list is sorted from most likely to least likely.
:param sent: The sentence to be parsed
:type sent: list(str)
:rtype: iter(Tree)
"""
if overridden(self.batch_iter_parse):
return self.batch_iter_parse([sent])[0]
elif overridden(self.nbest_parse) or overridden(self.batch_nbest_parse):
return iter(self.nbest_parse(sent))
elif overridden(self.parse) or overridden(self.batch_parse):
tree = self.parse(sent)
if tree: return iter([tree])
else: return iter([])
else:
raise NotImplementedError()
示例15: tag
def tag(self, tokens):
"""
Determine the most appropriate tag sequence for the given
token sequence, and return a corresponding list of tagged
tokens. A tagged token is encoded as a tuple C{(token, tag)}.
@rtype: C{list} of C{(token, tag)}
"""
if overridden(self.batch_tag):
return self.batch_tag([tokens])[0]
else:
raise NotImplementedError()