class_docstr: Class containing unit tests for nltk.tgrep.
class_docstr_tok: ["Class","containing","unit","tests","for","nltk.tgrep","."]
docstr: Test matching on nodes based on NLTK tree position.
docstr_tok: ["Test","matching","on","nodes","based","on","NLTK","tree","position","."]
code: def test_node_tree_position(self):
      """
      Test matching on nodes based on NLTK tree position.
      """
      tree = ParentedTree.fromstring(
          "(S (NP-SBJ x) (NP x) (NNP x) (VP x))"
      )
      # test all tree positions that are not leaves
      leaf_positions = {
          tree.leaf_treeposition(x) for x in range(len(tree.leaves()))
      }
      tree_positions = [
          x for x in tree.treepositions() if x not in leaf_positions
      ]
      for position in tree_positions:
          node_id = f"N{position}"
          tgrep_positions = list(tgrep.tgrep_positions(node_id, [tree]))
          self.assertEqual(len(tgrep_positions[0]), 1)
          self.assertEqual(tgrep_positions[0][0], position)
  
imports: import unittest
  from nltk import tgrep
  from nltk.tree import ParentedTree
label_desc: Use image node_id 15 for calling the TestSequenceFunctions obj's underlying member method code with example usage: obj.test_node_tree_position() without return types