Skip to content

Instantly share code, notes, and snippets.

@v3c70r
Created September 25, 2015 04:27
Show Gist options
  • Save v3c70r/bae31144a2e15155b0f6 to your computer and use it in GitHub Desktop.
Save v3c70r/bae31144a2e15155b0f6 to your computer and use it in GitHub Desktop.
'''
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