예제 #1
0
                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)
        except IOError:
            plot_to_shot[show][episode_name] = preprocessor.plot_shot_assigner(plot_to_sub[show][episode_name], sub_to_shot[show][episode_name])
            with open(plot_to_shot_path, 'w') as fp1:
                json.dump(plot_to_shot[show][episode_name], fp1)

# fetch transcripts
# fetching transcripts depends on the availability of one...
action_stamps = {}
for show in list_of_shows:
    action_stamps[show] = {}

# get list of directory files
for show in list_of_shows:
    # check whether transcripts exist?
    dir_entries = [i[:-4] for i in os.listdir(DIR_TRANSC[show]) if i.endswith('.txt')]
    for f in dir_entries:  # got rid of txt suffix
        # storing the processed part in json
예제 #2
0
            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
episode_num, query = 1, "jimmy"
shot_timestamps, video_descr, shots_list = similarity_fn1(
    time_stamps[episode_num - 1],
    sub_to_shot[episode_num - 1],
    idf[episode_num - 1],
    tf_idf[episode_num - 1],
    plot_sentences[episode_num - 1],
    plot_to_sub[episode_num - 1],
    sub_text[episode_num - 1],
    untouched_sub_text[episode_num - 1],
    plot_to_shot[episode_num - 1],
    query,