nodes: 0, module; 1, function_definition; 2, function_name:_get_terminals_and_nonterminals; 3, parameters; 4, block; 5, identifier:sentence_graph; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, return_statement; 11, comment:"""
      Given a TigerSentenceGraph, returns a sorted list of terminal node
      IDs, as well as a sorted list of nonterminal node IDs.
  
      Parameters
      ----------
      sentence_graph : TigerSentenceGraph
          a directed graph representing one syntax annotated sentence from
          a TigerXML file
  
      Returns
      -------
      terminals, nonterminals : list of str
          a sorted list of terminal node IDs and a sorted list of
          nonterminal node IDs
      """; 12, assignment; 13, assignment; 14, identifier:node_id; 15, call; 16, block; 17, expression_list; 18, identifier:terminals; 19, call; 20, identifier:nonterminals; 21, call; 22, attribute; 23, argument_list; 24, if_statement; 25, call; 26, line_continuation:\; 27, call; 28, identifier:set; 29, argument_list; 30, identifier:set; 31, argument_list; 32, identifier:sentence_graph; 33, identifier:nodes_iter; 34, comparison_operator:sentence_graph.out_degree(node_id) > 0; 35, comment:# all nonterminals (incl. root); 36, block; 37, else_clause; 38, identifier:sorted; 39, argument_list; 40, identifier:sorted; 41, argument_list; 42, call; 43, integer:0; 44, expression_statement; 45, comment:# terminals; 46, block; 47, call; 48, keyword_argument; 49, call; 50, keyword_argument; 51, attribute; 52, argument_list; 53, call; 54, expression_statement; 55, identifier:list; 56, argument_list; 57, identifier:key; 58, identifier:natural_sort_key; 59, identifier:list; 60, argument_list; 61, identifier:key; 62, identifier:natural_sort_key; 63, identifier:sentence_graph; 64, identifier:out_degree; 65, identifier:node_id; 66, attribute; 67, argument_list; 68, call; 69, identifier:terminals; 70, identifier:nonterminals; 71, identifier:nonterminals; 72, identifier:add; 73, identifier:node_id; 74, attribute; 75, argument_list; 76, identifier:terminals; 77, identifier:add; 78, identifier:node_id
code: def _get_terminals_and_nonterminals(sentence_graph):
      """
      Given a TigerSentenceGraph, returns a sorted list of terminal node
      IDs, as well as a sorted list of nonterminal node IDs.
  
      Parameters
      ----------
      sentence_graph : TigerSentenceGraph
          a directed graph representing one syntax annotated sentence from
          a TigerXML file
  
      Returns
      -------
      terminals, nonterminals : list of str
          a sorted list of terminal node IDs and a sorted list of
          nonterminal node IDs
      """
      terminals = set()
      nonterminals = set()
      for node_id in sentence_graph.nodes_iter():
          if sentence_graph.out_degree(node_id) > 0:
              # all nonterminals (incl. root)
              nonterminals.add(node_id)
          else:  # terminals
              terminals.add(node_id)
      return sorted(list(terminals), key=natural_sort_key), \
          sorted(list(nonterminals), key=natural_sort_key)