Delete create_dataset.py
Browse files- create_dataset.py +0 -31
create_dataset.py
DELETED
@@ -1,31 +0,0 @@
|
|
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"{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'], 'selected_text': row['selected_text']})+"\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")
|
20 |
-
raw_dset = DatasetDict()
|
21 |
-
raw_dset["train"] = train_dset
|
22 |
-
raw_dset["test"] = test_dset
|
23 |
-
|
24 |
-
for split, dset in raw_dset.items():
|
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()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|