for n in ns:
    for idxs in itertools.combinations(ns, n):
        yield [' '.join(words[i:j]) for i, j in zip((0,) + idxs, idxs + (
            None,))]
Split a string into all possible ordered phrases