def test_summary_class(self): """ test make summary dict """ self.input_module.input_fast_large_file() wiki_vector = self.input_module.get_vector() wn_summary_list = APP_ROOT + '/../../Data/wn_summary_list.txt' self.input_module = InputFileCython(wn_summary_list) self.input_module.input_special_format_file() file_list = self.input_module.get_file_data() count = 0 class_word_vector = {} class_average_vector = {} for file in file_list: self.input_module = InputFileCython(APP_ROOT + "/../../Data/wn_summary/" + file.strip()) self.input_module.input_special_format_file() if count == 0: class_summary = ClassSummaryCython(file.strip(), self.input_module.get_file_data(), wiki_vector) else: class_summary = ClassSummaryCython(file.strip(), self.input_module.get_file_data(), wiki_vector, class_word_vector, class_average_vector) class_word_vector, class_average_vector = class_summary.summary_class() fo = open(APP_ROOT + "/../../Data/test/" + file.strip() + "_vector.txt", 'w') sys.stdout = fo print(class_average_vector[file.strip()]) fo.close() sys.stdout = sys.__stdout__ class_summary_cosine_similarity_cython = ClassSummaryCosineSimilarityCython(class_average_vector) class_summary_cosine_similarity_cython.summary_class_use_cosine_similarity()
def test_summary_class(self): """ test make summary dict """ file_list = self.input_module.get_file_data() wn_average_vector_list = APP_ROOT + '/../../Data/wn_average_vector_list.txt' self.input_module = InputFileCython(wn_average_vector_list) self.input_module.input_special_format_file() vector_list = self.input_module.get_file_data() class_word_vector = {} class_average_vector = {} for file in file_list: self.input_module = InputFileCython(APP_ROOT + "/../../Data/wn_summary/" + file.strip()) self.input_module.input_special_format_file() if file.strip() not in class_word_vector: word_list = re.sub("\]|\[|\'", "", self.input_module.get_file_data()[0].strip()) class_word_vector.update({file.strip().replace(".txt", ""): word_list.split(",")}) for vector in vector_list: self.input_module = InputFileCython(APP_ROOT + "/../../Data/wn_summary_multi/" + vector.strip()) self.input_module.input_special_format_file() vector_list = [] if vector.strip() not in class_average_vector: for value in self.input_module.get_file_data(): value = re.sub("\]|\[|\'", "", value.strip()) [vector_list.append(each_value) for each_value in value.split(" ") if each_value != ""] vector_list = list(map(float, vector_list)) class_average_vector.update({vector.strip().replace(".txt_vector.txt", ""): vector_list}) class_summary_cosine_similarity_cython = ClassSummaryCosineSimilarityCython(class_word_vector, class_average_vector) class_summary_cosine_similarity_cython.summary_class_use_cosine_similarity()
def test_summary_class(self): """ test make summary dict """ file_list = self.input_module.get_file_data() wn_average_vector_list = APP_ROOT + '/../../Data/wn_average_vector_list.txt' self.input_module = InputFileCython(wn_average_vector_list) self.input_module.input_special_format_file() vector_list = self.input_module.get_file_data() class_word_vector = {} class_average_vector = {} for file in file_list: self.input_module = InputFileCython(APP_ROOT + "/../../Data/wn_summary/" + file.strip()) self.input_module.input_special_format_file() if file.strip() not in class_word_vector: word_list = re.sub( "\]|\[|\'", "", self.input_module.get_file_data()[0].strip()) class_word_vector.update( {file.strip().replace(".txt", ""): word_list.split(",")}) for vector in vector_list: self.input_module = InputFileCython( APP_ROOT + "/../../Data/wn_summary_multi/" + vector.strip()) self.input_module.input_special_format_file() vector_list = [] if vector.strip() not in class_average_vector: for value in self.input_module.get_file_data(): value = re.sub("\]|\[|\'", "", value.strip()) [ vector_list.append(each_value) for each_value in value.split(" ") if each_value != "" ] vector_list = list(map(float, vector_list)) class_average_vector.update({ vector.strip().replace(".txt_vector.txt", ""): vector_list }) class_summary_cosine_similarity_cython = ClassSummaryCosineSimilarityCython( class_word_vector, class_average_vector) class_summary_cosine_similarity_cython.summary_class_use_cosine_similarity( )
def test_summary_class(self): """ test make summary dict """ self.input_module.input_fast_large_file() wiki_vector = self.input_module.get_vector() wn_summary_list = APP_ROOT + '/../../Data/wn_summary_list.txt' self.input_module = InputFileCython(wn_summary_list) self.input_module.input_special_format_file() file_list = self.input_module.get_file_data() count = 0 class_word_vector = {} class_average_vector = {} for file in file_list: self.input_module = InputFileCython(APP_ROOT + "/../../Data/wn_summary/" + file.strip()) self.input_module.input_special_format_file() if count == 0: class_summary = ClassSummaryCython( file.strip(), self.input_module.get_file_data(), wiki_vector) else: class_summary = ClassSummaryCython( file.strip(), self.input_module.get_file_data(), wiki_vector, class_word_vector, class_average_vector) class_word_vector, class_average_vector = class_summary.summary_class( ) fo = open( APP_ROOT + "/../../Data/test/" + file.strip() + "_vector.txt", 'w') sys.stdout = fo print(class_average_vector[file.strip()]) fo.close() sys.stdout = sys.__stdout__ class_summary_cosine_similarity_cython = ClassSummaryCosineSimilarityCython( class_average_vector) class_summary_cosine_similarity_cython.summary_class_use_cosine_similarity( )