# Path: metrics/tester.py
# def load_textfiles(references, hypothesis):
# def score(ref, hypo):
# def main():
#     BLEU_1 = 0.
#     BLEU_2 = 0.
#     BLEU_3 = 0.
#     BLEU_4 = 0.
#     ROUGE_L = 0.
#     BLEU_1 = BLEU_1/num_files
#     BLEU_2 = BLEU_2/num_files
#     BLEU_3 = BLEU_3/num_files
#     BLEU_4 = BLEU_4/num_files
#     ROUGE_L = ROUGE_L/num_files


import pandas as pd
from metrics import tester
                           self.num_hypothesis * self.steps_per_prediction,
                           self.steps_per_prediction)

        for hypothesis in self.hypotheses.T:
            bleu_1,bleu_2, bleu_3, bleu_4, rouge = self.__evaluate_one_ref_hypothesis_pair(self.reference,hypothesis)
            self.bleu_1.append(bleu_1)
            self.bleu_2.append(bleu_2)
            self.bleu_3.append(bleu_3)
            self.bleu_4.append(bleu_4)
            self.rouge.append(rouge)

    def __evaluate_one_ref_hypothesis_pair(self, refs, hyps):
        """

        :param refs:
        :param hyps:
        :return:
        """
        # Dump the data into the corresponding files
        for index,pair in enumerate(zip(refs,hyps)):
            file_ref_nm = self.reference_store_loc + '/ref' + str(index) + '.txt'
            file_hyp_nm = self.hypothesis_store_loc + '/gen' + str(index) + '.txt'
            ref_file = open(file_ref_nm,'w')
            hyp_file = open(file_hyp_nm,'w')
            ref_file.write(str(pair[0]))
            if pair[1] != 'nan':
                hyp_file.write(str(pair[1]))
            else:
                hyp_file.write('')
        # Call the tester function to get the evaluations

# Path: metrics/tester.py
# def load_textfiles(references, hypothesis):
# def score(ref, hypo):
# def main():
#     BLEU_1 = 0.
#     BLEU_2 = 0.
#     BLEU_3 = 0.
#     BLEU_4 = 0.
#     ROUGE_L = 0.
#     BLEU_1 = BLEU_1/num_files
#     BLEU_2 = BLEU_2/num_files
#     BLEU_3 = BLEU_3/num_files
#     BLEU_4 = BLEU_4/num_files
#     ROUGE_L = ROUGE_L/num_files


# Path: helpers/metric.py
import pandas as pd
from metrics import tester

                           self.num_hypothesis * self.steps_per_prediction,
                           self.steps_per_prediction)

        for hypothesis in self.hypotheses.T:
            bleu_1,bleu_2, bleu_3, bleu_4, rouge = self.__evaluate_one_ref_hypothesis_pair(self.reference,hypothesis)
            self.bleu_1.append(bleu_1)
            self.bleu_2.append(bleu_2)
            self.bleu_3.append(bleu_3)
            self.bleu_4.append(bleu_4)
            self.rouge.append(rouge)

    def __evaluate_one_ref_hypothesis_pair(self, refs, hyps):
        """

        :param refs:
        :param hyps:
        :return:
        """
        # Dump the data into the corresponding files
        for index,pair in enumerate(zip(refs,hyps)):
            file_ref_nm = self.reference_store_loc + '/ref' + str(index) + '.txt'
            file_hyp_nm = self.hypothesis_store_loc + '/gen' + str(index) + '.txt'
            ref_file = open(file_ref_nm,'w')
            hyp_file = open(file_hyp_nm,'w')
            ref_file.write(str(pair[0]))
            if pair[1] != 'nan':
                hyp_file.write(str(pair[1]))
            else:
                hyp_file.write('')
        # Call the tester function to get the evaluations

        return tester.main()