nltk.extract_test_sentences()

nltk.extract_test_sentences(string, comment_chars='#%;', encoding=None)[source]

Parses a string with one test sentence per line. Lines can optionally begin with:

  • a bool, saying if the sentence is grammatical or not, or
  • an int, giving the number of parse trees is should have,

The result information is followed by a colon, and then the sentence. Empty lines and lines beginning with a comment char are ignored.

Returns:

a list of tuple of sentences and expected results, where a sentence is a list of str, and a result is None, or bool, or int

Parameters:
  • comment_charsstr of possible comment characters.
  • encoding – the encoding of the string, if it is binary