def load_data_from_files(list_, file_dict, prefix): data = {} for pair in list_: # load autocomplete objects into dict from file data sentence = linecache.getline(file_dict[pair[0]], pair[1])[:-1] data['*'.join(map(str, pair))] = AutoCompleteData( sentence, file_dict[pair[0]][:file_dict[pair[0]].index(".")], pair[1], AutoCompleteData.get_score(prefix, sentence)) return data
def build_objects(results, data_collection, files_dict, new_string): list_of_auto_completes = [] for i, sentence in enumerate(results): line = linecache.getline(files_dict[sentence[0]], sentence[1]) new_object = AutoCompleteData(line, files_dict[sentence[0]], sentence[1], AutoCompleteData.get_score(new_string)) list_of_auto_completes.append(new_object) return list_of_auto_completes