def sorted_cluster_representatives(filenames_for_synsets): global filenames_for_synsets_global filenames_for_synsets_global = filenames_for_synsets config = ConfigParser.SafeConfigParser() config.read('../config.cfg') mcl_filename = config.get('Filenames for Pickles', 'mcl_clusters_filename') mcl_json_filename = config.get('Filenames for Pickles', 'mcl_clusters_as_json_filename') cluster_representatives = read_cluster_representatives(mcl_filename) sorted_cluster_representatives = [] for cluster in cluster_representatives: sorted_cluster = sorted(cluster, cmp=compare_representatives, reverse=True) sorted_cluster_representatives.append(sorted_cluster) write_json_file(sorted_cluster_representatives, mcl_json_filename)
def main(): # import configuration config = ConfigParser.SafeConfigParser() config.read('../config.cfg') visual_data_dir = config.get('Directories', 'visual-data-dir') visual_features_filename = config.get('Filenames for Pickles', 'visual_features_filename') visual_features_filename = visual_features_filename.replace("##","all") # combine all visual jsons in path to one json monster_json = {} for json_file in find_metajsons_to_process_in_dir(visual_data_dir): parsed_json = parse_json_file(json_file) if parsed_json == None: print "Could not read json file %s" % json_file continue monster_json.update(parsed_json) write_json_file(monster_json,visual_features_filename)