def preprocess_text(X, vocab_size, oov=2, start=1, index_from=3):
    """
    Preprocess the text by adding start and offset indices given padding. Also
    limit the max index using

    Arguments:
        X (List): dataset
        vocab_size (int): a given vocab_size limit. From a dataset. Words less frequent can
                    get capped when they are beyond the vocab size.
        oov (int): the index used for oov word, typically 2
        start (int): the index used as the start of a sentence, typically 1
        index_from (int): the index offset, typically 3, given having 0 (padding),
                          1 (start), 2 (OOV).
    """

    if start is not None:
        X = [[start] + [w + index_from for w in x] for x in X]
    else:
        X = [[w + index_from for w in x] for x in X]

    if vocab_size is None:
        vocab_size = max([max(x) for x in X])

    if oov is not None:
        X = [[oov if w >= vocab_size else w for w in x] for x in X]

    return X