import random


def split_partition(annotations):
    """Randomly split annotations into train (80%), dev (10%), and test (10%) sets"""

    train_annotations = dict()
    dev_annotations = dict()
    test_annotations = dict()            
    doc_names = list(annotations.keys()) 
    random.seed(100) #To ensure the shuffle always return the same result (allows reproducibility)
    random.shuffle(doc_names)
        
    split_1 = int(0.8 * len(doc_names))
    split_2 = int(0.9 * len(doc_names))

    train_doc_names = doc_names[:split_1]
    dev_doc_names = doc_names[split_1:split_2]
    test_doc_names = doc_names[split_2:]
    
    for doc in train_doc_names:
        train_annotations[doc] = annotations[doc]
        
    for doc in dev_doc_names:
        dev_annotations[doc] = annotations[doc]
        
    for doc in test_doc_names:
        test_annotations[doc] = annotations[doc]

    return train_annotations, dev_annotations, test_annotations