Datasets:
Commit ·
7a2647a
1
Parent(s): 10f1402
Fixed Bug for multi_eurlex
Browse files- lextreme.py +10 -1
lextreme.py
CHANGED
|
@@ -52,6 +52,7 @@ class LextremeConfig(datasets.BuilderConfig):
|
|
| 52 |
hf_hub_name,
|
| 53 |
language="multilingual",
|
| 54 |
config_name="default",
|
|
|
|
| 55 |
label_classes=None,
|
| 56 |
task_type=None,
|
| 57 |
**kwargs,
|
|
@@ -67,6 +68,7 @@ class LextremeConfig(datasets.BuilderConfig):
|
|
| 67 |
hf_hub_name: `string`, huggingface dataset identifier
|
| 68 |
hf_hub_name: `string`, the language of the dataset (either multilingual or a single language ISO code)
|
| 69 |
config_name: `string`, huggingface dataset config name
|
|
|
|
| 70 |
label_classes: `list[string]`, the list of classes if the label is
|
| 71 |
categorical. If not provided, then the label will be of type
|
| 72 |
`datasets.Value('float32')`.
|
|
@@ -82,6 +84,7 @@ class LextremeConfig(datasets.BuilderConfig):
|
|
| 82 |
self.hf_hub_name = hf_hub_name
|
| 83 |
self.language = language
|
| 84 |
self.config_name = config_name
|
|
|
|
| 85 |
self.label_classes = label_classes
|
| 86 |
self.task_type = task_type
|
| 87 |
|
|
@@ -3041,6 +3044,7 @@ _MULTI_EURLEX_LEVEL_1 = {
|
|
| 3041 |
}
|
| 3042 |
"""
|
| 3043 |
,
|
|
|
|
| 3044 |
"label_classes": [
|
| 3045 |
"100149",
|
| 3046 |
"100160",
|
|
@@ -3067,6 +3071,7 @@ _MULTI_EURLEX_LEVEL_1 = {
|
|
| 3067 |
}
|
| 3068 |
_MULTI_EURLEX_LEVEL_2 = {
|
| 3069 |
**_MULTI_EURLEX_LEVEL_1,
|
|
|
|
| 3070 |
"label_classes": [
|
| 3071 |
"100215",
|
| 3072 |
"100211",
|
|
@@ -3199,6 +3204,7 @@ _MULTI_EURLEX_LEVEL_2 = {
|
|
| 3199 |
}
|
| 3200 |
_MULTI_EURLEX_LEVEL_3 = {
|
| 3201 |
**_MULTI_EURLEX_LEVEL_1,
|
|
|
|
| 3202 |
"label_classes": [
|
| 3203 |
"1754",
|
| 3204 |
"5881",
|
|
@@ -4064,7 +4070,10 @@ class LEXTREME(datasets.GeneratorBasedBuilder):
|
|
| 4064 |
def _generate_examples(self, split):
|
| 4065 |
"""This function returns the examples in the raw (text) form."""
|
| 4066 |
# we can just do this, since all our datasets are available on the huggingface hub
|
| 4067 |
-
dataset = datasets.load_dataset(self.config.hf_hub_name,
|
|
|
|
|
|
|
|
|
|
| 4068 |
for id, item in enumerate(dataset):
|
| 4069 |
# In case we have a class label and not just a string: convert it back to the string
|
| 4070 |
label_col = self.config.label_col
|
|
|
|
| 52 |
hf_hub_name,
|
| 53 |
language="multilingual",
|
| 54 |
config_name="default",
|
| 55 |
+
label_level=None,
|
| 56 |
label_classes=None,
|
| 57 |
task_type=None,
|
| 58 |
**kwargs,
|
|
|
|
| 68 |
hf_hub_name: `string`, huggingface dataset identifier
|
| 69 |
hf_hub_name: `string`, the language of the dataset (either multilingual or a single language ISO code)
|
| 70 |
config_name: `string`, huggingface dataset config name
|
| 71 |
+
label_level: `string`, the label level (only necessary for multieurlex)
|
| 72 |
label_classes: `list[string]`, the list of classes if the label is
|
| 73 |
categorical. If not provided, then the label will be of type
|
| 74 |
`datasets.Value('float32')`.
|
|
|
|
| 84 |
self.hf_hub_name = hf_hub_name
|
| 85 |
self.language = language
|
| 86 |
self.config_name = config_name
|
| 87 |
+
self.label_level = label_level
|
| 88 |
self.label_classes = label_classes
|
| 89 |
self.task_type = task_type
|
| 90 |
|
|
|
|
| 3044 |
}
|
| 3045 |
"""
|
| 3046 |
,
|
| 3047 |
+
"label_level": "level_1",
|
| 3048 |
"label_classes": [
|
| 3049 |
"100149",
|
| 3050 |
"100160",
|
|
|
|
| 3071 |
}
|
| 3072 |
_MULTI_EURLEX_LEVEL_2 = {
|
| 3073 |
**_MULTI_EURLEX_LEVEL_1,
|
| 3074 |
+
"label_level": "level_2",
|
| 3075 |
"label_classes": [
|
| 3076 |
"100215",
|
| 3077 |
"100211",
|
|
|
|
| 3204 |
}
|
| 3205 |
_MULTI_EURLEX_LEVEL_3 = {
|
| 3206 |
**_MULTI_EURLEX_LEVEL_1,
|
| 3207 |
+
"label_level": "level_3",
|
| 3208 |
"label_classes": [
|
| 3209 |
"1754",
|
| 3210 |
"5881",
|
|
|
|
| 4070 |
def _generate_examples(self, split):
|
| 4071 |
"""This function returns the examples in the raw (text) form."""
|
| 4072 |
# we can just do this, since all our datasets are available on the huggingface hub
|
| 4073 |
+
dataset = datasets.load_dataset(self.config.hf_hub_name,
|
| 4074 |
+
self.config.config_name,
|
| 4075 |
+
label_level=self.config.label_level,
|
| 4076 |
+
split=split)
|
| 4077 |
for id, item in enumerate(dataset):
|
| 4078 |
# In case we have a class label and not just a string: convert it back to the string
|
| 4079 |
label_col = self.config.label_col
|