from typing import Iterable
from typing import List


def get_segment(document: Iterable[List[str]], target_length: int) -> List[str]:
    """ Get the segment (the sequence of string tokens) from a document which
    contains encoded sentences. Return the segment if the target length is
    achieved, raise ValueError otherwise. """
    segment = []
    for sentence in document:
        segment.extend(sentence)
        if len(segment) < target_length:
            continue
        return segment
    raise ValueError