def index_data(word_index, data):
    """Function to convert a dataset to indexed instances based on a given word index.

    :param word_index: given mapping of words to indices
    :param data: list of text instances
    :return: list of indexed instances
    """
    data_vector = []
    for instance in data:
        instance_vector = [word_index["<START>"]]
        for word in instance:
            instance_vector.append(word_index.get(word, word_index["<UNK>"]))
        data_vector.append(instance_vector)
    return data_vector