luketheduke
commited on
Commit
•
512e89f
1
Parent(s):
9fea188
Upload create_dataset.py
Browse files- create_dataset.py +23 -0
create_dataset.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from datasets import load_dataset
|
2 |
+
|
3 |
+
|
4 |
+
def main():
|
5 |
+
raw_dset = load_dataset("glue", "rte")
|
6 |
+
raw_dset = raw_dset.rename_column("sentence1", "text1")
|
7 |
+
raw_dset = raw_dset.rename_column("sentence2", "text2")
|
8 |
+
text_labs = ["entailment", "not entailment"]
|
9 |
+
|
10 |
+
for split, dset in raw_dset.items():
|
11 |
+
label_text = []
|
12 |
+
for i in dset["label"]:
|
13 |
+
if i >= 0:
|
14 |
+
label_text.append(text_labs[i])
|
15 |
+
else:
|
16 |
+
label_text.append("unlabeled")
|
17 |
+
dset = dset.add_column("label_text", label_text)
|
18 |
+
dset.to_json(f"{split}.jsonl")
|
19 |
+
|
20 |
+
|
21 |
+
if __name__ == "__main__":
|
22 |
+
main()
|
23 |
+
print("Job's done!")
|