def parse_cdr_annotations_pubtator(entity_type, subset):
    """Get each annotation in the BC5CDR corpus with documents in PubTator format.

    Requires:
        entity_type: is str, either "Chemical" or "Disease"
        subset: is str, either "train", "dev", "test" or "all"
    
    Ensures:
        annotations: is dict, each key is document str, values are list with all the annotations in document
    """
    
    corpus_dir = "BioCreative-V-CDR-Corpus/CDR_Data/CDR.Corpus.v010516/"    
    annotations = dict()
    filenames = list()
    
    if subset == "train":
        filenames.append("CDR_TrainingSet.PubTator.txt")
    elif subset == "dev":
        filenames.append("CDR_DevelopmentSet.PubTator.txt")
    elif subset == "test":
        filenames.append("CDR_TestSet.PubTator.txt")

    elif subset == "all":
        filenames.append("CDR_TrainingSet.PubTator.txt")
        filenames.append("CDR_DevelopmentSet.PubTator.txt")
        filenames.append("CDR_TestSet.PubTator.txt")
  
    for filename in filenames:

        with open(corpus_dir + filename, 'r') as corpus_file:
            data = corpus_file.readlines()
            corpus_file.close()

            for line in data:
                line_data = line.split("\t")
                document_id = line_data[0]
           
                if len(line_data) == 6 and line_data[4] == entity_type:
                    mesh_id = line_data[5].strip("\n")
                    
                    annotation_text = line_data[3]
                    annotation = (mesh_id, annotation_text)
            
                    if document_id in annotations.keys():
                        current_values = annotations[document_id]
                        current_values.append(annotation)
                        annotations[document_id] = current_values
                    
                    else:
                        annotations[document_id] = [annotation]

    return annotations