nltk.tgrep.tgrep_nodes

nltk.tgrep.tgrep_nodes(pattern, trees, search_leaves=True)[source]

Return the tree nodes in the trees which match the given pattern.

Parameters
  • pattern (str or output of tgrep_compile()) – a tgrep search pattern

  • trees (iter(ParentedTree) or iter(Tree)) – a sequence of NLTK trees (usually ParentedTrees)

  • search_leaves (bool) – whether to return matching leaf nodes

Return type

iter(tree nodes)