Datasets:

Modalities:
Text
Formats:
parquet
Languages:
Danish
Libraries:
Datasets
Dask
pere commited on
Commit
e09e74c
1 Parent(s): ef00add

Upload src/download_culturax.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. src/download_culturax.py +21 -0
src/download_culturax.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import json
3
+ from datasets import load_dataset
4
+
5
+ def download_culturax(language, output_file):
6
+ # Load the CulturaX dataset for the specified language
7
+ dataset = load_dataset("uonlp/CulturaX", language, use_auth_token=True)
8
+
9
+ # Write a limited number of samples to the JSON Lines file
10
+ with open(output_file, 'w', encoding='utf-8') as f:
11
+ for example in dataset['train']:
12
+ json.dump(example, f)
13
+ f.write("\n")
14
+
15
+ if __name__ == "__main__":
16
+ parser = argparse.ArgumentParser(description="Download a part of CulturaX and save it as a JSON Lines file.")
17
+ parser.add_argument('--language', type=str, required=True, help="The language code for the part of CulturaX to download (e.g., 'no' for Norwegian).")
18
+ parser.add_argument('--output_file', type=str, required=True, help="The output JSON Lines file.")
19
+
20
+ args = parser.parse_args()
21
+ download_culturax(args.language, args.output_file)