Datasets:
Update: UTCD column types
Browse files
utcd.py
CHANGED
@@ -96,15 +96,19 @@ class Utcd(datasets.GeneratorBasedBuilder):
|
|
96 |
|
97 |
def _info(self):
|
98 |
dnms = self._get_dataset_names()
|
99 |
-
labels = [_config[dnm]['splits'][split]['labels'] for dnm in dnms for split in ['train', 'test']]
|
|
|
|
|
|
|
100 |
|
101 |
-
labels = sorted(set().union(*labels)) # drop duplicate labels across datasets
|
102 |
return datasets.DatasetInfo(
|
103 |
description=_DESCRIPTION,
|
104 |
features=datasets.Features(
|
105 |
text=datasets.Value(dtype='string'),
|
106 |
-
labels=datasets.Sequence(feature=datasets.ClassLabel(names=labels), length=-1), # for multi-label
|
107 |
-
|
|
|
|
|
108 |
),
|
109 |
homepage=_URL
|
110 |
# TODO: citation
|
@@ -128,8 +132,9 @@ class Utcd(datasets.GeneratorBasedBuilder):
|
|
128 |
id_ = 0
|
129 |
for path in filepath: # each file for one split of one dataset
|
130 |
dnm = path.split(os.sep)[-2]
|
|
|
131 |
with open(path, encoding='utf-8') as fl:
|
132 |
dset = json.load(fl)
|
133 |
for txt, labels in dset.items():
|
134 |
-
yield id_, dict(text=txt, labels=labels, dataset_name=dnm)
|
135 |
id_ += 1
|
|
|
96 |
|
97 |
def _info(self):
|
98 |
dnms = self._get_dataset_names()
|
99 |
+
# labels = [_config[dnm]['splits'][split]['labels'] for dnm in dnms for split in ['train', 'test']]
|
100 |
+
# labels = sorted(set().union(*labels)) # drop duplicate labels across datasets
|
101 |
+
aspects = [d['aspect'] for dnm, d in _config.items()]
|
102 |
+
aspects = sorted(set(aspects)) # drop duplicate aspects
|
103 |
|
|
|
104 |
return datasets.DatasetInfo(
|
105 |
description=_DESCRIPTION,
|
106 |
features=datasets.Features(
|
107 |
text=datasets.Value(dtype='string'),
|
108 |
+
# labels=datasets.Sequence(feature=datasets.ClassLabel(names=labels), length=-1), # for multi-label
|
109 |
+
labels=datasets.Sequence(feature=datasets.Value(dtype='string'), length=-1),
|
110 |
+
dataset_name=datasets.ClassLabel(names=dnms),
|
111 |
+
aspect=datasets.ClassLabel(names=aspects)
|
112 |
),
|
113 |
homepage=_URL
|
114 |
# TODO: citation
|
|
|
132 |
id_ = 0
|
133 |
for path in filepath: # each file for one split of one dataset
|
134 |
dnm = path.split(os.sep)[-2]
|
135 |
+
aspect = _config[dnm]['aspect']
|
136 |
with open(path, encoding='utf-8') as fl:
|
137 |
dset = json.load(fl)
|
138 |
for txt, labels in dset.items():
|
139 |
+
yield id_, dict(text=txt, labels=labels, dataset_name=dnm, aspect=aspect)
|
140 |
id_ += 1
|