2to3 (compiles, not tested)
[tag_parser.git] / tests / stand_alone / counting.py
blob246587af1a83a5269dd3505d1dc97a71374154f5
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/ambiguous 3/grammar.yaml")
12 parser = TagChartParser(grammar)
14 for s in ["john died completely"]:
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_EARLEY_STRATEGY))))
18 print(parser.nbest_parse(tokens))
19 print(parser.parse(tokens))