nreimers commited on
Commit
0d5359c
1 Parent(s): 3fdf5d7

update create script

Browse files
Files changed (3) hide show
  1. create_dataset.py +13 -2
  2. test.jsonl +2 -2
  3. train.jsonl +2 -2
create_dataset.py CHANGED
@@ -1,8 +1,19 @@
1
  from datasets import DatasetDict, load_dataset
2
-
 
3
 
4
  def main():
5
  label2id = {"positive": 2, "neutral": 1, "negative": 0}
 
 
 
 
 
 
 
 
 
 
6
  train_dset = load_dataset("csv", data_files="raw_data/train_csv", split="train")
7
  train_dset = train_dset.remove_columns(["selected_text"])
8
  test_dset = load_dataset("csv", data_files="raw_data/train_csv", split="train")
@@ -14,7 +25,7 @@ def main():
14
  dset = dset.rename_column("sentiment", "label_text")
15
  dset = dset.map(lambda x: {"label": label2id[x["label_text"]]}, num_proc=8)
16
  dset.to_json(f"{split}.jsonl")
17
-
18
 
19
  if __name__ == "__main__":
20
  main()
 
1
  from datasets import DatasetDict, load_dataset
2
+ import csv
3
+ import json
4
 
5
  def main():
6
  label2id = {"positive": 2, "neutral": 1, "negative": 0}
7
+
8
+ for split in ["train", "test"]:
9
+ input_file = csv.DictReader(open(f"raw_data/{split}_csv"))
10
+
11
+ with open(f'{split}.jsonl', 'w') as fOut:
12
+ for row in input_file:
13
+ fOut.write(json.dumps({'textID': row['textID'], 'text': row['text'], 'label': label2id[row['sentiment']], 'label_text': row['sentiment']})+"\n")
14
+
15
+
16
+ """
17
  train_dset = load_dataset("csv", data_files="raw_data/train_csv", split="train")
18
  train_dset = train_dset.remove_columns(["selected_text"])
19
  test_dset = load_dataset("csv", data_files="raw_data/train_csv", split="train")
 
25
  dset = dset.rename_column("sentiment", "label_text")
26
  dset = dset.map(lambda x: {"label": label2id[x["label_text"]]}, num_proc=8)
27
  dset.to_json(f"{split}.jsonl")
28
+ """
29
 
30
  if __name__ == "__main__":
31
  main()
test.jsonl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:088f0450a3f18fbd3768548b666cbf0e00b0e71a835f88dc4f6408156d1e7710
3
- size 5277301
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:da4fd3fdf9f0cd04198588f748bb854af2bf2a2a59e7126e281ebdba6f81b175
3
+ size 503351
train.jsonl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:750bbef4e42ca44a0a6fef4625748f75014d15e128fb6b18752d34f64a4681bc
3
- size 3743264
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d43dee14f2ed23d635338ac401d2b5e00371eaa18e26eb246375cfc886800e11
3
+ size 3931114