Example #1
0
    current_sentence_counter = 0
    counter = 0
    start_range = 0
    end_range = 0
    for sentence_number in list_of_sentence_numbers:
        #sentence_number = 4514
        print("we start in sentence # ", sentence_number)

        selected_sentence = DBHelperMethod.get_sentence_by(sentence_number)
        undiac_words = get_undiac_words_for_selected_sentence(
            list_of_all_words_and_sent_num, sentence_number)

        dic_words_for_selected_sent = get_dic_words_for_selected_sentence(
            dictionary, undiac_words)
        rnn_input = DBHelperMethod.get_un_diacritized_chars_by(
            sentence_number, 'testing')

        num_of_chars_in_selected_sent = len(rnn_input)

        end_range = num_of_chars_in_selected_sent + start_range

        nn_op_letters = dp.concatenate_char_and_diacritization(
            ip_letters[start_range:end_range:1],
            nn_labels[start_range:end_range:1])

        expected_letters = expected_op_letters[start_range:end_range:1]

        location = loc[start_range:end_range:1]

        # Post Processing
        RNN_Predicted_Chars_And_Its_Location = dp.create_letter_location_object(
Example #2
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 = RNNOPProcessingHelperMethod.get_neurons_numbers_with_highest_output_value(
            rnn_output)

        list_of_available_diacritics = DBHelperMethod.get_all_diacritics()
        RNN_Predicted_diacritics = RNNOPProcessingHelperMethod.\
            deduce_from_rnn_op_predicted_chars(list_of_available_diacritics, neurons_with_highest_probability)

        IP_Undiacritized_Chars = DBHelperMethod.get_un_diacritized_chars_by(
            sentence_number, type)
        RNN_Predicted_chars = WordLetterProcessingHelperMethod.attach_diacritics_to_chars(
            IP_Undiacritized_Chars, RNN_Predicted_diacritics)

        RNN_Predicted_Chars_Count = WordLetterProcessingHelperMethod.get_chars_count_for_each_word_in_this(
            selected_sentence)
        RNN_Predicted_Chars_And_Its_Location = WordLetterProcessingHelperMethod.get_location_of_each_char(
            RNN_Predicted_chars, RNN_Predicted_Chars_Count)

        # Post Processing
        RNN_Predicted_Chars_After_Sukun = SukunCorrection.sukun_correction(
            deepcopy(RNN_Predicted_Chars_And_Its_Location))
        RNN_Predicted_Chars_After_Fatha = FathaCorrection.fatha_correction(
            deepcopy(RNN_Predicted_Chars_After_Sukun))
        RNN_Predicted_Chars_After_Dictionary = DictionaryCorrection.get_diac_version_with_smallest_dist(
            deepcopy(RNN_Predicted_Chars_After_Fatha), sentence_number)