1 # This Python file uses the following encoding: utf-8
3 Created on May 19, 2011
7 from mjacob
.nltk
.grammar
.TreeAdjoiningGrammar
import TreeAdjoiningGrammar
8 from mjacob
.nltk
.parse
.tag
.TagChartParser
import TagChartParser
9 from mjacob
.nltk
.parse
.tag
.earley
.rules
import TAG_EARLEY_STRATEGY
11 grammar
= TreeAdjoiningGrammar(filename
="../integration/tag_chart/cross_serial_2/grammar.yaml")
12 parser
= TagChartParser(grammar
)
14 for s
in ["Jan Piet Marie de kinderen zag helpen leren zwemmen"]:
16 chart
= parser
.chart_parse(tokens
)
17 # for goal_edge, deduction in chart.deduction_paths(grammar.start().symbol(), TAG_EARLEY_STRATEGY):
18 # print "GOAL: %s" % (goal_edge)
20 # for x,y,z in deduction:
21 # print "% 6i %s <- %s" % (i, x, y)
26 print(" %s" % ("\n ".join(tree
.pprint(margin
=10000) for tree
in chart
.parses(grammar
.start().symbol(), TAG_EARLEY_STRATEGY
))))
27 #print parser.nbest_parse(tokens)
28 #print parser.parse(tokens)