Commit
•
26b0cea
1
Parent(s):
941974a
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", "qnli")
|
6 |
+
raw_dset = raw_dset.rename_column("question", "text1")
|
7 |
+
raw_dset = raw_dset.rename_column("sentence", "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!")
|