This repository contains the script to align sentences from two text files using the MITRA API to facilitate a more efficient collaboration between the data collection team and MITRA. The script reads two text files, splits them into lists of sentences, sends these lists to our API for alignment, and writes the returned data to a TSV file.
- Python 3.6 or higher
requestslibrary
-
Clone the repository:
git clone https://github.com/dharmamitra/mitra-aligner-client cd mitra-aligner-client -
Install the required Python packages:
pip install requests
The script align.py takes three command-line parameters:
--input-a: Path to the first input text file. Each line should be a separate sentence. This can be either Chinese or English/Tibetan/Sanskrit.--input-b: Path to the second input text file. Each line should be a separate sentence. This can be either Chinese or English/Tibetan/Sanskrit.--output: Path to the output TSV file.
The order of the files is not important, i.e. it could be first the Chinese and then the English, or the other way round.
Run the script with the required parameters as follows:
python align.py --input-a <path_to_first_text_file> --input-b <path_to_second_text_file> --output <path_to_output_tsv_file>Please be aware that depending on the length of the files, this can take a while to complete. A file with a few hundred lines input and output can take a few minutes, files with thousands of lines can take much longer.
The aligner is already using GPUs and optimized for performance, its difficult to make it faster than this!