def arity_parse_demo():
 print()
 print(u'A grammar with no arity constraints. Each DependencyProduction')
 print(u'specifies a relationship between one head word and only one')
 print(u'modifier word.')
 grammar = DependencyGrammar.fromstring(u"\n    'fell' -> 'price' | 'stock'\n    'price' -> 'of' | 'the'\n    'of' -> 'stock'\n    'stock' -> 'the'\n    ")
 print(grammar)
 print()
 print(u"For the sentence 'The price of the stock fell', this grammar")
 print(u'will produce the following three parses:')
 pdp = ProjectiveDependencyParser(grammar)
 trees = pdp.parse([u'the', u'price', u'of', u'the', u'stock', u'fell'])
 for tree in trees:
  print(tree)
 print()
 print(u'By contrast, the following grammar contains a ')
 print(u'DependencyProduction that specifies a relationship')
 print(u"between a single head word, 'price', and two modifier")
 print(u"words, 'of' and 'the'.")
 grammar = DependencyGrammar.fromstring(u"\n    'fell' -> 'price' | 'stock'\n    'price' -> 'of' 'the'\n    'of' -> 'stock'\n    'stock' -> 'the'\n    ")
 print(grammar)
 print()
 print(u'This constrains the number of possible parses to just one:')
 pdp = ProjectiveDependencyParser(grammar)
 trees = pdp.parse([u'the', u'price', u'of', u'the', u'stock', u'fell'])
 for tree in trees:
  print(tree)

def arity_parse_demo ( ) : print ( ) print ( u'A grammar with no arity constraints. Each DependencyProduction' ) print ( u'specifies a relationship between one head word and only one' ) print ( u'modifier word.' ) grammar = DependencyGrammar . fromstring ( u"\n    'fell' -> 'price' | 'stock'\n    'price' -> 'of' | 'the'\n    'of' -> 'stock'\n    'stock' -> 'the'\n    " ) print ( grammar ) print ( ) print ( u"For the sentence 'The price of the stock fell', this grammar" ) print ( u'will produce the following three parses:' ) pdp = ProjectiveDependencyParser ( grammar ) trees = pdp . parse ( [ u'the' , u'price' , u'of' , u'the' , u'stock' , u'fell' ] ) for tree in trees : print ( tree ) print ( ) print ( u'By contrast, the following grammar contains a ' ) print ( u'DependencyProduction that specifies a relationship' ) print ( u"between a single head word, 'price', and two modifier" ) print ( u"words, 'of' and 'the'." ) grammar = DependencyGrammar . fromstring ( u"\n    'fell' -> 'price' | 'stock'\n    'price' -> 'of' 'the'\n    'of' -> 'stock'\n    'stock' -> 'the'\n    " ) print ( grammar ) print ( ) print ( u'This constrains the number of possible parses to just one:' ) pdp = ProjectiveDependencyParser ( grammar ) trees = pdp . parse ( [ u'the' , u'price' , u'of' , u'the' , u'stock' , u'fell' ] ) for tree in trees : print ( tree )
a demonstration showing the creation of a dependencygrammar in which a specific number of modifiers is listed for a given head .