I'm getting a SyntaxError
using a lambda with a three-tuple
candidates = [' '.join(word for word, pos, chunk in group).lower()
for key, group in itertools.groupby(all_chunks, lambda (word,pos,chunk): chunk != 'O') if key]
where all_chunks
is a list
.
the error is
for key, group in itertools.groupby(all_chunks, lambda (word,pos,chunk): chunk != 'O') if key]
^
SyntaxError: invalid syntax
That syntax is valid in Python2, but not in Python3.
The tuple is a three-tuple, otherwise getting a TypeError
error
13 # join constituent chunk words into a single chunked phrase
---> 14 candidates = [' '.join(word for word, pos, chunk in group).lower()
15 for key, group in itertools.groupby(all_chunks, lambda word,pos,chunk: chunk != 'O') if key]
16
TypeError: <lambda>() missing 2 required positional arguments: 'pos' and 'chunk'