def load_testing_data(): dp.establish_db_connection() sequence_list = [] padded_output = [] #sentence_numbers = [] testing_dataset = DBHelperMethod.load_dataset_by_type("testing") #testing_dataset = DBHelperMethod.load_dataset_by_type_and_sentence_number_for_testing_purpose("testing", 3228) #sentence_numbers.append(3228) sentence_numbers = DBHelperMethod.get_list_of_sentence_numbers_by( "testing") labels_and_equiv_encoding = dp.get_label_table() for each_sentence_number in sentence_numbers: selected_sentence = testing_dataset[numpy.where( testing_dataset[:, 3] == str(each_sentence_number))] x, y = pad_data(selected_sentence, selected_sentence[:, [0, 1]], labels_and_equiv_encoding) sequence_list.append(x) padded_output.append(y) padded_input, vocabulary, vocabulary_inv = convert_input_to_vocab( sequence_list) padded_output = numpy.array(list(chain(*padded_output))) testing_words = np.take(testing_dataset, 4, axis=1) input_testing_letters = np.take(testing_dataset, 0, axis=1) op_testing_letters = np.take(testing_dataset, 5, axis=1) sent_num = np.take(testing_dataset, 3, axis=1) letters_loc = np.take(testing_dataset, 6, axis=1) undiac_word = np.take(testing_dataset, 7, axis=1) return padded_input, padded_output, vocabulary, vocabulary_inv, testing_words, input_testing_letters, op_testing_letters,\ sent_num, letters_loc, undiac_word
def load_testing_data(): dp.establish_db_connection() sequence_list = [] padded_output = [] training_dataset = DBHelperMethod.load_dataset_by_type("testing") sentence_numbers = DBHelperMethod.get_list_of_sentence_numbers_by( "testing") labels_and_equiv_encoding = dp.get_label_table() for each_sentence_number in sentence_numbers: selected_sentence = training_dataset[numpy.where( training_dataset[:, 3] == str(each_sentence_number))] x, y = pad_data(selected_sentence, selected_sentence[:, [0, 1]], labels_and_equiv_encoding) sequence_list.append(x) padded_output.append(y) padded_input, vocabulary, vocabulary_inv = convert_input_to_vocab( sequence_list) padded_output = numpy.array(list(chain(*padded_output))) return padded_input, padded_output, vocabulary, vocabulary_inv
nn_labels = labels[nn_indices] nn_labels = np.take(nn_labels, 1, axis=1) expected_labels = labels[expected_indices] expected_labels = np.take(expected_labels, 1, axis=1) if len(nn_labels) == len(expected_labels) and len(nn_labels) == len( ip_letters): pass else: raise Exception("mismatch in number of elements in the array") nn_op_letters = dp.concatenate_char_and_diacritization( ip_letters, nn_labels) expected_op_letters = op_letters list_of_sentence_numbers = DBHelperMethod.get_list_of_sentence_numbers_by( 'testing') list_of_all_words_and_sent_num = get_all_undiac_words('testing') current_sentence_counter = 0 counter = 0 start_range = 0 end_range = 0 all_sentences = DBHelperMethod.get_all_sentences_by('testing') for sentence_number in list_of_sentence_numbers: #sentence_number = 2838 print("we will begin processing in sentence number:", sentence_number) indices_of_selected_sentence = np.where( all_sentences == str(sentence_number)) selected_sentence1 = list( all_sentences[indices_of_selected_sentence[0], 0]) #selected_sentence1 = DBHelperMethod.get_sentence_by(sentence_number, 'testing')
import SukunCorrection import WordLetterProcessingHelperMethod import os import glob from copy import deepcopy # actual = rnnop extension = 'csv' path = 'D:\Repos\\results\ATB3\\5\\new\\ff\\files\\' current_row_1 = 0 current_row_2 = 0 Total_Error = 0 Total_Error_without_last_char = 0 if __name__ == "__main__": type = 'testing' list_of_sentence_numbers = DBHelperMethod.get_list_of_sentence_numbers_by( type) os.chdir(path) result = [i for i in glob.glob('*.{}'.format(extension))] current_sentence_counter = 0 counter = 0 if len(list_of_sentence_numbers) != len(result): raise Exception('Mismatch In Number Of Sentences') for file_name, sentence_number in zip(result, list_of_sentence_numbers): selected_sentence = DBHelperMethod.get_sentence_by(sentence_number) rnn_output = ExcelHelperMethod.read_rnn_op_csv_file(path + file_name) neurons_with_highest_probability, neurons_op_value = RNNOPProcessingHelperMethod.get_neurons_numbers_with_highest_output_value( rnn_output)