import random


def shuffle_split(documents, labels, split):
    """Shuffle data to ensure random class distribution in train/test split.

    :param documents: all textual reviews in corpus
    :type documents: list of strings
    :param labels: all class labels in corpus
    :type labels: list of strings
    :param split: boundary for train/test sets
    :type split: int

    :rtype: (list, list, list)
    :return: documents train-set, documents test-set, labels train-set, labels test-set
    """
    tuples = [(doc, label) for doc, label in zip(documents, labels)]
    random.shuffle(tuples)
    X, Y = zip(*tuples)

    split_point = int(split*len(X))

    Xtrain = X[:split_point]
    Ytrain = Y[:split_point]
    Xtest = X[split_point:]
    Ytest = Y[split_point:]

    return Xtrain, Xtest, Ytrain, Ytest