def lower_than(val_x, threshold): return (val_x < threshold) threshold_val = 0.5 filtered_results = filter_results(full_results_LOADED, threshold_val, greater_than, sim_measure='ed') # print("++++++++++") # print("****FILTEREDRESULTS******") # print(filtered_results) sim_phrase_true_path = "/media/sirivasv/DATAL/MCC/DATASUBSET/MTC-ANN-2.0/metadata/MTC-ANN-phrase-similarity.csv" sim_phrase_true_keys = ["filename", "phrase_id", "ann1", "ann2", "ann3"] sim_phrase_true_dict = csv_to_dict(sim_phrase_true_path, sim_phrase_true_keys) # print("++++++++++") # print("*****TRUELABELS*****") # print(sim_phrase_true_dict) pattern_prec_recall = pattern_precision_recall(full_results_LOADED, melody_dict_LOADED, sim_phrase_true_dict, 'ed', "ann1") # print("++++++++++") # print("*****PRECRECALL*****") # print(pattern_prec_recall) sum_prec = 0.0 sum_recall = 0.0 for pattrn in pattern_prec_recall: sum_prec += pattrn["precision"]
tune_family_data_path = "/media/sirivasv/DATAL/MCC/DATASUBSET/MTC-ANN-2.0/metadata/MTC-ANN-tune-family-labels.csv" tune_family_data_keys = ["filename", "tunefamily"] tune_family_id_path = "/media/sirivasv/DATAL/MCC/DATASUBSET/mtc-fs-1.0/MTC-FS-1.0/metadata/MTC-FS.csv" tune_family_id_keys = [ "filename", "songid", "source_id", "serial_number", "page", "singer_id_s", "date_of_recording", "place_of_recording", "latitude", "longitude", "title", "firstline", "textfamily_id", "tunefamily_id", "tunefamily", "type", "voice_strophe_number", "voice_strophe", "image_filename_s", "audio_filename", "variation", "confidence" ] music_files_path = "/media/sirivasv/DATAL/MCC/DATASUBSET/MTC-ANN-2.0/krn/" meta_dict = csv_to_dict(tune_family_data_path, tune_family_data_keys) for m_i, m in enumerate(meta_dict): meta_dict[m_i]["tunefamily_separated"] = meta_dict[m_i][ "tunefamily"].replace("_", " ") meta_dict = add_tunefamily_ids(meta_dict, tune_family_id_path, tune_family_id_keys) ts = time.time() with open('./MetaDict_{0}.json'.format(str(ts)), 'w') as outfile: json.dump(meta_dict, outfile) melody_dict = extract_melodies_from_corpus(music_files_path, meta_dict) ts = time.time() pickle.dump(melody_dict, open('./MelodyDict_{0}.pkl'.format(str(ts)), "wb")) phrase_dict = filter_phrases(melody_dict) ts = time.time()