nlp - Python 2.x sublist parameter equivalent in 3.x -


i'm working nlp experiments in python , wanted implement function in python 3.x though lambda expansion here giving me hard time , i'm not sure how it'd implemented in 3.x; suggestions?

    candidates = [' '.join(word word, pos, chunk in group).lower()               key, group in itertools.groupby(all_chunks, lambda (word,pos,chunk): chunk != 'o') if key] 

the error on piece since sublist parameters not supported in 3.x

lambda (word,pos,chunk) 

the original source extract_candidate_words function here: http://bdewilde.github.io/blog/2014/09/23/intro-to-automatic-keyphrase-extraction/

the syntax in python3 be:

lambda word__pos__chunk: word__pos__chunk[2] != 'o' 

a lambda function 3 item tuple (word, pos, chunk) gets converted word__pos__chunk positional arguments, word__pos__chunk[2] access third item example.

more information: pep-3113


Comments