import argparse | |
import json | |
from datasets import load_dataset | |
def download_culturax(language, output_file): | |
# Load the CulturaX dataset for the specified language | |
dataset = load_dataset("uonlp/CulturaX", language, use_auth_token=True) | |
# Write a limited number of samples to the JSON Lines file | |
with open(output_file, 'w', encoding='utf-8') as f: | |
for example in dataset['train']: | |
json.dump(example, f) | |
f.write("\n") | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser(description="Download a part of CulturaX and save it as a JSON Lines file.") | |
parser.add_argument('--language', type=str, required=True, help="The language code for the part of CulturaX to download (e.g., 'no' for Norwegian).") | |
parser.add_argument('--output_file', type=str, required=True, help="The output JSON Lines file.") | |
args = parser.parse_args() | |
download_culturax(args.language, args.output_file) | |