nltk.tgrep.tgrep_positions

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

Return the tree positions 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 positions)