list(extract_chunks(l, 'NP'))
l = [('What', 'B-NP'), ('is', 'B-VP'), ('the', 'B-NP'), ('airspeed', 'I-NP'
    ), ('of', 'B-PP'), ('an', 'B-NP'), ('unladen', 'I-NP'), ('swallow',
    'I-NP'), ('?', 'O')]
list(extract_chunks(l, 'NP'))
How to extract chunks from BIO chunked sentences? - python