json.dump(idf[show][episode_name], fp2) json.dump(tf_idf[show][episode_name], fp3) # subtitle to shot mapping sub_to_shot = {} for show in list_of_shows: sub_to_shot[show] = {} for show in list_of_shows: for episode_name in video_file_names[show]: sub_to_shot_path = DIR_SUBSHOT[show]+'/'+episode_name+'_proc_subshot.json' try: with open(sub_to_shot_path, 'r') as fp1: sub_to_shot[show][episode_name] = json.load(fp1) except IOError: sub_to_shot[show][episode_name] = preprocessor.sub_shot_assigner(sub_stamps[show][episode_name], scene_stamps[show][episode_name]) with open(sub_to_shot_path, 'w') as fp1: json.dump(sub_to_shot[show][episode_name], fp1) # plot to shot mapping plot_to_shot = {} for show in list_of_shows: plot_to_shot[show] = {} for show in list_of_shows: for episode_name in video_file_names[show]: # storing the processed part in json plot_to_shot_path = DIR_PLOTSHOT[show]+'/'+episode_name+'_proc_plotshot.json' try: with open(plot_to_shot_path, 'r') as fp1: plot_to_shot[show][episode_name] = json.load(fp1)
t1, t2, t3 = plot_sub_assigner(plot_sentences[index], sub_text[index]) plot_to_sub[index], idf[index], tf_idf[index] = t1, t2, t3 json.dump(plot_to_sub[index], fp1) json.dump(idf[index], fp2) json.dump(tf_idf[index], fp3) sub_to_shot = [None for i in range(no_episodes)] for index, vid_file in enumerate(file_names): # storing the processed part in json sub_to_shot_path = DIR_SUBSHOT + "/" + vid_file + "_proc_subshot.json" try: with open(sub_to_shot_path, "r") as fp1: sub_to_shot[index] = json.load(fp1) except IOError: with open(sub_to_shot_path, "w") as fp1: sub_to_shot[index] = sub_shot_assigner(sub_stamps[index], scene_stamps[index]) json.dump(sub_to_shot[index], fp1) plot_to_shot = [None for i in range(no_episodes)] for index, vid_file in enumerate(file_names): # storing the processed part in json plot_to_shot_path = DIR_PLOTSHOT + "/" + vid_file + "_proc_plotshot.json" try: with open(plot_to_shot_path, "r") as fp1: plot_to_shot[index] = json.load(fp1) except IOError: with open(plot_to_shot_path, "w") as fp1: plot_to_shot[index] = plot_shot_assigner(plot_to_sub[index], sub_to_shot[index]) json.dump(plot_to_shot[index], fp1) shot_timestamps, video_descr, shots_list = None, None, None