2to3 (compiles, not tested)
[tag_parser.git] / tests / stand_alone / prefix_valid_testing2.py
blobd5a4822d77f16af3e9ebf982a21c5874d5e78219
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.prefix_valid_earley.rules import TAG_PREFIX_VALID_EARLEY_STRATEGY
11 grammar = TreeAdjoiningGrammar(filename="../integration/tag_chart/squares/grammar.yaml")
12 parser = TagChartParser(grammar, strategy=TAG_PREFIX_VALID_EARLEY_STRATEGY)
14 for s in ["a a a a"]:
15 tokens = s.split(' ')
16 chart = parser.chart_parse(tokens)
17 print(" %s" % ("\n ".join(str(x) for x in chart.parses(grammar.start().symbol(), TAG_PREFIX_VALID_EARLEY_STRATEGY))))
18 #print parser.nbest_parse(tokens)
19 #print parser.parse(tokens)