I want to run a code in Python 3. It works in Python 2.7 and the input is not empty. Some parts of the code are as follows:
parser = nltk.ChartParser(zinc_grammar.GCFG)
parse_trees = [next(parser.parse(t)) for t in tokens]
But it shows the StopIteration error on the bottom line. Does anyone know how to solve it? Is there any alternative for it?
I realized that the problem is from the definition of the
tokens
because I usedlambda
function. I changed it and the problem is solved.