2to3 (compiles, not tested)
[tag_parser.git] / tests / stand_alone / cross_serial.py
blob406f79cb6f0b0af3e395736e1fa5094c9d78392b
1 # This Python file uses the following encoding: utf-8
2 '''
3 Created on May 19, 2011
5 @author: mjacob
6 '''
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"]:
15 tokens = s.split(' ')
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)
19 # i = 1
20 # for x,y,z in deduction:
21 # print "% 6i %s <- %s" % (i, x, y)
22 # for tree in z:
23 # print " %s" % (z,)
24 # i += 1
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)