Upload emotions_dataset.py
Browse files- emotions_dataset.py +9 -3
emotions_dataset.py
CHANGED
@@ -4,7 +4,7 @@ from typing import List
|
|
4 |
|
5 |
import datasets
|
6 |
import pandas as pd
|
7 |
-
from datasets import ClassLabel, Value
|
8 |
|
9 |
_URLS = {
|
10 |
"go_emotions": {
|
@@ -105,7 +105,7 @@ class EmotionsDataset(datasets.GeneratorBasedBuilder):
|
|
105 |
splits.append(datasets.SplitGenerator(name=k,
|
106 |
gen_kwargs={"filepaths": downloaded_files,
|
107 |
"dataset": k,
|
108 |
-
"license": v}))
|
109 |
else:
|
110 |
k = self.config.name
|
111 |
v = _URLS.get(k)
|
@@ -113,7 +113,7 @@ class EmotionsDataset(datasets.GeneratorBasedBuilder):
|
|
113 |
splits.append(datasets.SplitGenerator(name=k,
|
114 |
gen_kwargs={"filepaths": downloaded_files,
|
115 |
"dataset": k,
|
116 |
-
"license": v}))
|
117 |
return splits
|
118 |
|
119 |
def _generate_examples(self, filepaths, dataset, license):
|
@@ -131,6 +131,7 @@ class EmotionsDataset(datasets.GeneratorBasedBuilder):
|
|
131 |
"license": license,
|
132 |
"label": row[current_classes][row == 1].index.item()}
|
133 |
elif dataset == "daily_dialog":
|
|
|
134 |
emo_mapping = {0: "no emotion", 1: "anger", 2: "disgust",
|
135 |
3: "fear", 4: "happiness", 5: "sadness", 6: "surprise"}
|
136 |
for i, filepath in enumerate(filepaths):
|
@@ -138,6 +139,7 @@ class EmotionsDataset(datasets.GeneratorBasedBuilder):
|
|
138 |
emotions = open(os.path.join(filepath, "ijcnlp_dailydialog/dialogues_emotion.txt"), "r").read()
|
139 |
text = open(os.path.join(filepath, "ijcnlp_dailydialog/dialogues_text.txt"), "r").read()
|
140 |
else:
|
|
|
141 |
archive = zipfile.ZipFile(filepath, 'r')
|
142 |
emotions = archive.open("ijcnlp_dailydialog/dialogues_emotion.txt", "r").read().decode()
|
143 |
text = archive.open("ijcnlp_dailydialog/dialogues_text.txt", "r").read().decode()
|
@@ -155,3 +157,7 @@ class EmotionsDataset(datasets.GeneratorBasedBuilder):
|
|
155 |
"dataset": dataset,
|
156 |
"license": license,
|
157 |
"label": emo_mapping[ce]}
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
import datasets
|
6 |
import pandas as pd
|
7 |
+
from datasets import ClassLabel, Value, load_dataset
|
8 |
|
9 |
_URLS = {
|
10 |
"go_emotions": {
|
|
|
105 |
splits.append(datasets.SplitGenerator(name=k,
|
106 |
gen_kwargs={"filepaths": downloaded_files,
|
107 |
"dataset": k,
|
108 |
+
"license": v.get("license")}))
|
109 |
else:
|
110 |
k = self.config.name
|
111 |
v = _URLS.get(k)
|
|
|
113 |
splits.append(datasets.SplitGenerator(name=k,
|
114 |
gen_kwargs={"filepaths": downloaded_files,
|
115 |
"dataset": k,
|
116 |
+
"license": v.get("license")}))
|
117 |
return splits
|
118 |
|
119 |
def _generate_examples(self, filepaths, dataset, license):
|
|
|
131 |
"license": license,
|
132 |
"label": row[current_classes][row == 1].index.item()}
|
133 |
elif dataset == "daily_dialog":
|
134 |
+
# TODO move outside
|
135 |
emo_mapping = {0: "no emotion", 1: "anger", 2: "disgust",
|
136 |
3: "fear", 4: "happiness", 5: "sadness", 6: "surprise"}
|
137 |
for i, filepath in enumerate(filepaths):
|
|
|
139 |
emotions = open(os.path.join(filepath, "ijcnlp_dailydialog/dialogues_emotion.txt"), "r").read()
|
140 |
text = open(os.path.join(filepath, "ijcnlp_dailydialog/dialogues_text.txt"), "r").read()
|
141 |
else:
|
142 |
+
# TODO check if this can be removed
|
143 |
archive = zipfile.ZipFile(filepath, 'r')
|
144 |
emotions = archive.open("ijcnlp_dailydialog/dialogues_emotion.txt", "r").read().decode()
|
145 |
text = archive.open("ijcnlp_dailydialog/dialogues_text.txt", "r").read().decode()
|
|
|
157 |
"dataset": dataset,
|
158 |
"license": license,
|
159 |
"label": emo_mapping[ce]}
|
160 |
+
|
161 |
+
|
162 |
+
temp = load_dataset("ma2za/emotions_dataset", name="daily_dialog")
|
163 |
+
print()
|