nltk.grammar.DependencyGrammar

class nltk.grammar.DependencyGrammar[source]

Bases: object

A dependency grammar. A DependencyGrammar consists of a set of productions. Each production specifies a head/modifier relationship between a pair of words.

__init__(productions)[source]

Create a new dependency grammar, from the set of Productions.

Parameters

productions (list(Production)) – The list of productions that defines the grammar

classmethod fromstring(input)[source]
contains(head, mod)[source]
Parameters
  • head (str) – A head word.

  • mod (str) – A mod word, to test as a modifier of ‘head’.

Returns

true if this DependencyGrammar contains a DependencyProduction mapping ‘head’ to ‘mod’.

Return type

bool