本文整理汇总了Python中nltk.tree.Tree.treeposition_spanning_leaves方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.treeposition_spanning_leaves方法的具体用法?Python Tree.treeposition_spanning_leaves怎么用?Python Tree.treeposition_spanning_leaves使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nltk.tree.Tree
的用法示例。
在下文中一共展示了Tree.treeposition_spanning_leaves方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_tense
# 需要导入模块: from nltk.tree import Tree [as 别名]
# 或者: from nltk.tree.Tree import treeposition_spanning_leaves [as 别名]
def _get_tense(cls, parse, token_indices, use_gold=False):
if len(token_indices) == 1:
return 'one_token'
parse_tree = Tree(parse['parsetree'])
start_index = min(token_indices)
end_index = max(token_indices) + 1
tree_position = parse_tree.treeposition_spanning_leaves(start_index, end_index)
arg_subtree = parse_tree[tree_position]
return cls._recurse_search_tag(arg_subtree, ['VP'], [])