Unso commited on
Commit
90be6a6
·
1 Parent(s): a86ad8f

python file to generate data

Browse files
Files changed (1) hide show
  1. create_dataset.py +20 -0
create_dataset.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datasets import load_dataset
2
+
3
+
4
+ def main():
5
+
6
+ raw_data = load_dataset("catalonia_independence", "spanish")
7
+ raw_data = raw_data.rename_column("LABEL", "label")
8
+ raw_data = raw_data.rename_column("TWEET", "text")
9
+ raw_data = raw_data.rename_column("id_str", "id")
10
+
11
+ labels = raw_data["train"].features["label"]
12
+
13
+
14
+ for split, dataset in raw_data.items():
15
+ dataset = dataset.map(lambda x: {"label_text": labels.int2str(x["label"])}, num_proc=4)
16
+ dataset.to_json(f"{split}.jsonl")
17
+
18
+ if __name__ == "__main__":
19
+ main()
20
+