nltk/nltk — Issue #156: Problem with pchart and empty prod rhs
Author: alexrudnick
Created: 2012-01-17 06:27:21+00:00
State: open

Hi,

The problem is to build a pchart with a WeightedGrammar when some of rhs of production rules are empty.

In the file pchart.py, line 77, you must verify that len(prod.rhs())>0

I send you the traceback

Traceback (most recent call last):
File "./__main__.py", line 63, in <module>
parser.main(cfg,rec[0])
File "/udd/ggaret/Documents/programme/11_04_2011_intro_proba/programme/parser.py", line 66, in main
parses = parser.nbest_parse(tokens,1)
File "/usr/lib/python2.6/site-packages/nltk/parse/pchart.py", line 228, in nbest_parse
queue.extend(bu.apply(chart, grammar, edge))
File "/usr/lib/python2.6/site-packages/nltk/parse/chart.py", line 967, in apply
return list(self.apply_iter(chart, grammar, *edges))
File "/usr/lib/python2.6/site-packages/nltk/parse/pchart.py", line 77, in apply_iter
if edge.lhs() == prod.rhs()[0]:
IndexError: tuple index out of range

Migrated from http://code.google.com/p/nltk/issues/detail?id=670