Upload emotions_dataset.py
Browse files- emotions_dataset.py +37 -17
emotions_dataset.py
CHANGED
@@ -3,22 +3,22 @@ from typing import List
|
|
3 |
|
4 |
import datasets
|
5 |
import pandas as pd
|
6 |
-
from datasets import ClassLabel, Value
|
7 |
|
8 |
-
|
9 |
-
"
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
"urls": ["http://yanran.li/files/ijcnlp_dailydialog.zip"],
|
19 |
"license": "CC BY-NC-SA 4.0"
|
20 |
}
|
21 |
-
|
22 |
|
23 |
_CLASS_NAMES = [
|
24 |
"no emotion",
|
@@ -68,6 +68,16 @@ class EmotionsDataset(datasets.GeneratorBasedBuilder):
|
|
68 |
name="all",
|
69 |
label_classes=_CLASS_NAMES,
|
70 |
features=["text", "label", "dataset", "license"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
)
|
72 |
]
|
73 |
|
@@ -88,12 +98,21 @@ class EmotionsDataset(datasets.GeneratorBasedBuilder):
|
|
88 |
|
89 |
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
90 |
splits = []
|
91 |
-
|
92 |
-
|
93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
gen_kwargs={"filepaths": downloaded_files,
|
95 |
-
"dataset":
|
96 |
-
"license":
|
97 |
return splits
|
98 |
|
99 |
def _generate_examples(self, filepaths, dataset, license):
|
@@ -130,4 +149,5 @@ class EmotionsDataset(datasets.GeneratorBasedBuilder):
|
|
130 |
"label": emo_mapping[ce]}
|
131 |
|
132 |
|
|
|
133 |
print()
|
|
|
3 |
|
4 |
import datasets
|
5 |
import pandas as pd
|
6 |
+
from datasets import ClassLabel, Value, load_dataset
|
7 |
|
8 |
+
_URLS = {
|
9 |
+
"go_emotions": {
|
10 |
+
"urls": [
|
11 |
+
"https://storage.googleapis.com/gresearch/goemotions/data/full_dataset/goemotions_1.csv",
|
12 |
+
"https://storage.googleapis.com/gresearch/goemotions/data/full_dataset/goemotions_2.csv",
|
13 |
+
"https://storage.googleapis.com/gresearch/goemotions/data/full_dataset/goemotions_3.csv",
|
14 |
+
],
|
15 |
+
"license": "apache license 2.0"
|
16 |
+
},
|
17 |
+
"daily_dialog": {
|
18 |
"urls": ["http://yanran.li/files/ijcnlp_dailydialog.zip"],
|
19 |
"license": "CC BY-NC-SA 4.0"
|
20 |
}
|
21 |
+
}
|
22 |
|
23 |
_CLASS_NAMES = [
|
24 |
"no emotion",
|
|
|
68 |
name="all",
|
69 |
label_classes=_CLASS_NAMES,
|
70 |
features=["text", "label", "dataset", "license"]
|
71 |
+
),
|
72 |
+
EmotionsDatasetConfig(
|
73 |
+
name="go_emotions",
|
74 |
+
label_classes=_CLASS_NAMES,
|
75 |
+
features=["text", "label", "dataset", "license"]
|
76 |
+
),
|
77 |
+
EmotionsDatasetConfig(
|
78 |
+
name="daily_dialog",
|
79 |
+
label_classes=_CLASS_NAMES,
|
80 |
+
features=["text", "label", "dataset", "license"]
|
81 |
)
|
82 |
]
|
83 |
|
|
|
98 |
|
99 |
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
100 |
splits = []
|
101 |
+
if self.config.name == "all":
|
102 |
+
for k, v in _URLS.items():
|
103 |
+
downloaded_files = dl_manager.download_and_extract(v.get("urls"))
|
104 |
+
splits.append(datasets.SplitGenerator(name=k,
|
105 |
+
gen_kwargs={"filepaths": downloaded_files,
|
106 |
+
"dataset": k,
|
107 |
+
"license": v}))
|
108 |
+
else:
|
109 |
+
k = self.config.name
|
110 |
+
v = _URLS.get(k)
|
111 |
+
downloaded_files = dl_manager.download_and_extract(v.get("urls"))
|
112 |
+
splits.append(datasets.SplitGenerator(name=k,
|
113 |
gen_kwargs={"filepaths": downloaded_files,
|
114 |
+
"dataset": k,
|
115 |
+
"license": v}))
|
116 |
return splits
|
117 |
|
118 |
def _generate_examples(self, filepaths, dataset, license):
|
|
|
149 |
"label": emo_mapping[ce]}
|
150 |
|
151 |
|
152 |
+
temp = load_dataset("ma2za/emotions_dataset", split="daily_dialog")
|
153 |
print()
|