def load_exp_synonyms(file_path): file = read_list(file_path) words = [] for line in file: line = line.split() words.extend(line) return words
def load_func_synonyms(file_path): file = read_list(file_path) res = {} for line in file: line = line.split() std_word = line[0] for word in line: res[word] = std_word return res
def load_function(file_path): file = read_list(file_path) function_name = ['type', 'level', 'price', 'frame', 'screen', 'pixel'] res = {} i = 0 while i < len(file): name = file[i] temp = {} i += 1 while i < len(file) and file[i] != '': line = file[i].split(':') for word in function_name: if word == line[0]: temp[word] = line[1].split() i += 1 res[name] = temp while i < len(file) and file[i] == '': i += 1 return res
def load_function(file_path): file = read_list(file_path) function_name = ['cpu', 'memory'] res = {} i = 0 while i < len(file): name = file[i] temp = {} i += 1 while i < len(file) and file[i] != '': line = file[i].split(':') for word in function_name: if word == line[0]: temp[word] = line[1] i += 1 res[name] = temp while i < len(file) and file[i] == '': i += 1 return res
def load_func_synonyms(file_path): file = read_list(file_path) res = {} for line in file: line = line.split() std_word = line[0] for word in line: res[word] = std_word return res def load_exp_synonyms(file_path): file = read_list(file_path) words = [] for line in file: line = line.split() words.extend(line) return words path = os.path.dirname(__file__) function_attr = load_function(path + '/data/camera_func_attr.txt') func_synonyms = load_func_synonyms(path + '/data/camera_func_synonyms.txt') good_words = read_list(path + '/data/good_words_camera.txt') bad_words = read_list(path + '/data/bad_words_camera.txt') exp_synonyms = load_exp_synonyms(path + '/data/camera_synonyms.txt') print(func_synonyms)
def load_func_synonyms(file_path): file = read_list(file_path) res = {} for line in file: line = line.split() std_word = line[0] for word in line: res[word] = std_word return res def load_exp_synonyms(file_path): file = read_list(file_path) words = [] for line in file: line = line.split() words.extend(line) return words function_attr = load_function(path + '/data/computer_function_attr.txt') func_synonyms = load_func_synonyms(path + '/data/computer_func_synonyms.txt') good_words = read_list(path + '/data/good_words.txt') bad_words = read_list(path + '/data/bad_words.txt') exp_synonyms = load_exp_synonyms(path + '/data/computer_exp_synonyms.txt')