nodes: 0, module; 1, function_definition; 2, function_name:save_sentences; 3, parameters; 4, block; 5, identifier:twg; 6, identifier:stmts; 7, identifier:filename; 8, default_parameter; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, for_statement; 15, comment:# Write sentences to CSV file; 16, expression_statement; 17, identifier:agent_limit; 18, integer:300; 19, comment:"""Write evidence sentences for stmts with ungrounded agents to csv file.
  
      Parameters
      ----------
      twg: list of tuple
          list of tuples of ungrounded agent_texts with counts of the
          number of times they are mentioned in the list of statements.
          Should be sorted in descending order by the counts.
          This is of the form output by the function ungrounded texts.
  
      stmts: list of :py:class:`indra.statements.Statement`
  
      filename : str
          Path to output file
  
      agent_limit : Optional[int]
          Number of agents to include in output file. Takes the top agents
          by count.
      """; 20, assignment; 21, assignment; 22, assignment; 23, call; 24, identifier:text; 25, identifier:unmapped_texts; 26, block; 27, call; 28, identifier:sentences; 29, list; 30, identifier:unmapped_texts; 31, list_comprehension; 32, identifier:counter; 33, integer:0; 34, attribute; 35, argument_list; 36, expression_statement; 37, expression_statement; 38, expression_statement; 39, if_statement; 40, identifier:write_unicode_csv; 41, argument_list; 42, subscript; 43, for_in_clause; 44, identifier:logger; 45, identifier:info; 46, binary_operator:'Getting sentences for top %d unmapped agent texts.' %
                  agent_limit; 47, assignment; 48, augmented_assignment; 49, augmented_assignment; 50, comparison_operator:counter >= agent_limit; 51, block; 52, identifier:filename; 53, identifier:sentences; 54, keyword_argument; 55, keyword_argument; 56, keyword_argument; 57, keyword_argument; 58, identifier:t; 59, integer:0; 60, identifier:t; 61, identifier:twg; 62, string; 63, identifier:agent_limit; 64, identifier:agent_sentences; 65, call; 66, identifier:sentences; 67, call; 68, identifier:counter; 69, integer:1; 70, identifier:counter; 71, identifier:agent_limit; 72, break_statement; 73, identifier:delimiter; 74, string; 75, identifier:quotechar; 76, string:'"'; 77, identifier:quoting; 78, attribute; 79, identifier:lineterminator; 80, string; 81, string_content:Getting sentences for top %d unmapped agent texts.; 82, identifier:get_sentences_for_agent; 83, argument_list; 84, identifier:map; 85, argument_list; 86, string_content:,; 87, identifier:csv; 88, identifier:QUOTE_MINIMAL; 89, string_content; 90, identifier:text; 91, identifier:stmts; 92, lambda; 93, identifier:agent_sentences; 94, escape_sequence:\r; 95, escape_sequence:\n; 96, lambda_parameters; 97, binary_operator:(text,) + tup; 98, identifier:tup; 99, tuple; 100, identifier:tup; 101, identifier:text
code: def save_sentences(twg, stmts, filename, agent_limit=300):
      """Write evidence sentences for stmts with ungrounded agents to csv file.
  
      Parameters
      ----------
      twg: list of tuple
          list of tuples of ungrounded agent_texts with counts of the
          number of times they are mentioned in the list of statements.
          Should be sorted in descending order by the counts.
          This is of the form output by the function ungrounded texts.
  
      stmts: list of :py:class:`indra.statements.Statement`
  
      filename : str
          Path to output file
  
      agent_limit : Optional[int]
          Number of agents to include in output file. Takes the top agents
          by count.
      """
      sentences = []
      unmapped_texts = [t[0] for t in twg]
      counter = 0
      logger.info('Getting sentences for top %d unmapped agent texts.' %
                  agent_limit)
      for text in unmapped_texts:
          agent_sentences = get_sentences_for_agent(text, stmts)
          sentences += map(lambda tup: (text,) + tup, agent_sentences)
          counter += 1
          if counter >= agent_limit:
              break
      # Write sentences to CSV file
      write_unicode_csv(filename, sentences, delimiter=',', quotechar='"',
                        quoting=csv.QUOTE_MINIMAL, lineterminator='\r\n')