Advertisement
Heruberuto

Untitled

Dec 16th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. import nltk
  2. grammar = nltk.CFG.fromstring(open("atis/atis-grammar-cnf.cfg").read())
  3. sentences = open("atis/atis-test-sentences.txt").read()
  4. testSentences = nltk.parse.util.extract_test_sentences(sentences,encoding="latin2")
  5.  
  6. # initialize the parser
  7. parser = nltk.parse.BottomUpChartParser(grammar)
  8. # parse all test sentences
  9. for sentence in testSentences:
  10.     parser.chart_parse(sentence[0])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement