Datasets:
File size: 941 Bytes
312d05b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
#! /usr/bin/env python3
'''
This script will download the dataset xezpeleta/ccmatrix_eng_eus_filtered from Hugging Face
with the following structure:
{
'id': 0, 'score': 1.2498578, 'translation':
{
'en': "He stands to God's word, and God's worship.",
'eu': 'Jaungoikoa goratzera bideratuta egongo da eta Jaungoikoa bere borondatea betez goratzen da.'
}
}
Then will create the following txt files:
- ccmatrix_filtered.en-eu.en
- ccmatrix_filtered.en-eu.eu
'''
from datasets import load_dataset
def main():
dataset = load_dataset('xezpeleta/ccmatrix_eng_eus_filtered')
# Create the txt files
with open('ccmatrix_filtered.en-eu.en', 'w') as en_file, open('ccmatrix_filtered.en-eu.eu', 'w') as eu_file:
for data in dataset['train']:
en_file.write(data['translation']['en'] + '\n')
eu_file.write(data['translation']['eu'] + '\n')
if __name__ == '__main__':
main() |