def split_corpus(data, train_amount, test_length=None):
    """ Split the sentences into train and test sets. If test_length
    is None, then the split is:

    train = the first 'train_length' number of sentences.
    test = the rest.

    If test_length is given, the split is:

    train = the first 'train_length' number of sentences.
    test = the last 'test_length' number of sentences.

    NOTE: train_amount + test_length must be less than the total number of
    sentences.

    """
    if 0 <= train_amount <= 1:
        train_length = int(len(data) * train_amount)
    else:
        train_length = train_amount  # number of sentences in training set
    train = data[:train_length]

    if test_length is None:
        test = data[train_length :]
    else: # test_length is number of testing sentences
        if train_length + test_length > len(data):
            raise ValueError("The corpus is not long enough to have that much training & testing data.")
        test = data[len(data)-test_length : ]
    return train, test