This repository contains three files (__init__.py
, files_reading.py
, and metrics.py
) that provide functionality for building an MT (Machine Translation) evaluation task. These files include functions for reading data, evaluating translations using various metrics, and calculating evaluation scores.
-
__init__.py
: This file serves as the initialization file for the package. It exports the following functions:calculate_bleu
: Calculates the BLEU score for a translation.calculate_meteor
: Calculates the METEOR score for a translation.calculate_ter
: Calculates the TER (Translation Edit Rate) score for a translation.calculate_rouge
: Calculates the ROUGE scores (ROUGE-1 F-measure and ROUGE-L F-measure) for a translation.calculate_bert_score
: Calculates the BERTScore for a translation.evaluate_with_comet
: Performs evaluation using the COMET model.
-
files_reading.py
: This file provides functions for reading data from CSV and Excel files. It exports the following functions:read_csv
: Reads a CSV file and returns the data as a Pandas DataFrame.read_excel
: Reads an Excel file and returns the data as a Pandas DataFrame.evaluate_translation
: Evaluates translations in a DataFrame using various metrics.
-
metrics.py
: This file contains the implementation of different evaluation metrics used for MT evaluation. It exports the following functions:calculate_bleu
: Calculates the BLEU score for a translation.calculate_meteor
: Calculates the METEOR score for a translation.calculate_ter
: Calculates the TER score for a translation.calculate_rouge
: Calculates the ROUGE scores for a translation.calculate_bert_score
: Calculates the BERTScore for a translation.evaluate_with_comet
: Performs evaluation using the COMET model.
To use these files for MT evaluation, follow these steps:
- Ensure that you have the required dependencies installed. You may need to install packages in
requirements.txt
- Use the imported functions to read data, evaluate translations, and calculate evaluation scores based on your requirements.
file_path = "path/to/your/data.csv" data = read_csv(file_path) data = evaluate_translation(data, 'candidate_column', 'reference_column') bleu_score = calculate_bleu(data['candidate_column'], data['reference_column'])
- Customize the code or add additional functions as needed to suit your specific MT evaluation task