Q: NLTK ConsecutiveNPChunker threw ValueError I tried working on the nltk.org book chapter 7. In particular, at here: http://www.nltk.org/book/ch07.html under section 3.2 there is a ConsecutiveNPChunker class. I tried to replicate the code. However, it consistently threw the following ValueError.
My code is as follows:
import nltk
from nltk.corpus import conll2000
train_sents = conll2000.chunked_sents('train.txt', chunk_types=['NP'])
class ConsecutiveNPChunker(nltk.ChunkParserI): # [_consec-chunker]
    def __init__(self, train_sents):
        tagged_sents = [[((w,t),c) for (w,t,c) in
                         nltk.chunk.tree2conlltags(sent)]
                        for sent in train_sents]
        self.tagger = ConsecutiveNPChunkTagger(tagged_sents)

    def parse(self, sentence):
        tagged_sents = self.tagger.tag(sentence)
        conlltags = [(w,t,c) for ((w,t),c) in tagged_sents]
        return nltk.chunk.conlltags2tree(conlltags)
def npchunk_features(sentence, i, history):
    word, pos = sentence[i]
    return {"pos": pos}
chunker = ConsecutiveNPChunker(train_sents)

The following is the error when I ran the program:
~/.pyenv/versions/3.4.3/envs/nlp/lib/python3.4/site-packages/nltk/tag/util.py in <listcomp>(.0)
     67 
     68     """
---> 69     return [w for (w, t) in tagged_sentence]
     70 
     71 

ValueError: need more than 1 value to unpack


A: You have an unpacking error, it is because you don't have the zip method, which takes n number of iterables and returns list of tuples.
So, in your code in def parse() method/function,
conlltags = [(w,t,c) for ((w,t),c) in tagged_sents] 
this should be 
conlltags = [(w,t,c) for ((w,t),c) in zip(tagged_sents)]

This will yield more than one value to unpack.
