def extract_nps(text, annotation):
    """
    Extract Noun Phrases from given text tokens and phrase annotations
    """
    np_starts = [i for i in range(len(annotation)) if annotation[i] == 'B-NP']
    np_indexes = []
    for s in np_starts:
        i = 1
        while s+i < len(annotation) and annotation[s + i] == 'I-NP':
            i += 1
        np_indexes.append((s, s + i))
    return [' '.join(text[s:e]) for s, e in np_indexes]