nltk.read_grammar(input, nonterm_parser, probabilistic=False, encoding=None)[source]

Return a pair consisting of a starting category and a list of Productions.

  • input – a grammar, either in the form of a string or else as a list of strings.
  • nonterm_parser – a function for parsing nonterminals. It should take a (string, position) as argument and return a (nonterminal, position) as result.
  • probabilistic (bool) – are the grammar rules probabilistic?
  • encoding (str) – the encoding of the grammar, if it is a binary string