def compare(file1,Type,file_write): count = 0; count_two = 0; #map_videos = dictionary(Type); map_videos = get_mapping(Type); target = open(file_write, 'a'); lines = [line.rstrip('\r\n') for line in open(file1)]; tot = len(lines); for i in range(len(lines)): a = lines[i].split(); index = a[0]; if map_videos['vid' + index].has_key(a[1]): count = count + 1; highest_frequency_word = get_highest_frequency(map_videos,'vid' + index); if a[1] == highest_frequency_word: count_two = count_two + 1; target.write(index); target.write(" "); target.write(a[1]); target.write(" "); target.write(highest_frequency_word); target.write("\n"); print count_two; target.close(); return count;
def write_type_to_file(Type): we = get_mapping(Type) file = open(Type + ".txt", "w") for i in range(1970): keys = we["vid" + ` i + 1 `].keys() file.write(keys[0]) file.write("\n") file.close()
def write_type_to_file(Type): we = get_mapping(Type) file = open(Type + '.txt', 'w') for i in range(1970): keys = we['vid' + ` i + 1 `].keys() file.write(keys[0]) file.write('\n') file.close()
def get_wup(file1,Type, flag): count = 0; #map_videos = dictionary(Type); map_videos = get_mapping(Type); lines = [line.rstrip('\r\n') for line in open(file1)]; tot = len(lines); for i in range(len(lines)): a = lines[i].split(); index = a[0]; highest_frequency_wup = 0; if flag == 1: highest_frequency_wup = get_highest_wup(map_videos,'vid' + index,a[1]); elif flag == 0: highest_frequency_wup = get_most_occuring_wup(map_videos,'vid' + index,a[1]); count = count + highest_frequency_wup; return count;