Created
September 25, 2015 04:27
-
-
Save v3c70r/bae31144a2e15155b0f6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
This is a NLTK testing script. | |
AITS: http://www.ai.sri.com/natural-language/projects/arpa-sls/atis.html | |
''' | |
import nltk; | |
#print "Loading Sentence... " | |
#rural = nltk.corpus.abc.words('rural.txt') | |
rural = "Jack saw Bob with my cookie".split() | |
rural = ['show', 'me', 'northwest', 'flights', 'to', 'detroit', '.'] | |
print "Loading CFG..." | |
AITSgrammar = nltk.data.load('grammars/large_grammars/atis.cfg') | |
parser = nltk.ChartParser(AITSgrammar) | |
chart = parser.chart_parse(rural); | |
#print len(list(chart.parses(AITSgrammar.start()))) | |
for tree in parser.parse(rural): | |
print(tree) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment