def create_netcdf_target_classes():
    execute_create_netcdf_target_classes_start_time = datetime.datetime.now()
    letter = []
    diacritics = []
    searchCounter = 0
    targetClass = []
    beforeWhileLoop = datetime.datetime.now()
    for eachItem in range(0, len(selected_letters_in_this_loop)):
        yourLabel = selected_letters_in_this_loop[eachItem][7]
        OneHotTargetClassNotFound = True

        decomposed_letter = WordLetterProcessingHelperMethod.decompose_diac_char_into_char_and_diacritics(
            yourLabel)
        if len(decomposed_letter) == 2 and decomposed_letter[1] == u'ّ':
            decomposed_letter[1] = u'َّ'
            letter.append(decomposed_letter[0])
            diacritics.append(decomposed_letter[1])
            yourLabel = WordLetterProcessingHelperMethod.attach_diacritics_to_chars(
                letter, diacritics)[0]

        while OneHotTargetClassNotFound:
            try:
                if listOfDiacritizedCharacter[searchCounter][1] == yourLabel:
                    OneHotTargetClassNotFound = False
                    targetClass.append(
                        listOfDiacritizedCharacter[searchCounter][0])
                    searchCounter = 0
                else:
                    searchCounter += 1
            except:
                x = 1
    afterWhileLoop = datetime.datetime.now()
    print "While Loop takes : ", afterWhileLoop - beforeWhileLoop

    global purified_target_class
    purified_target_class = []

    purified_target_class = np.array(targetClass)
    execute_create_netcdf_target_class_end_time = datetime.datetime.now()
    print "createNetCDFTargetClasses takes : ", \
        execute_create_netcdf_target_class_end_time - execute_create_netcdf_target_classes_start_time
コード例 #2
0
    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)

        # Expected OP