Upload indolem_ner_ugm.py with huggingface_hub
Browse files- indolem_ner_ugm.py +13 -13
indolem_ner_ugm.py
CHANGED
|
@@ -2,11 +2,11 @@ from pathlib import Path
|
|
| 2 |
from typing import Dict, List, Tuple
|
| 3 |
|
| 4 |
import datasets
|
| 5 |
-
from
|
| 6 |
-
from
|
| 7 |
|
| 8 |
-
from
|
| 9 |
-
from
|
| 10 |
|
| 11 |
_CITATION = """\
|
| 12 |
@inproceedings{koto-etal-2020-indolem,
|
|
@@ -56,7 +56,7 @@ _SUPPORTED_TASKS = [Tasks.NAMED_ENTITY_RECOGNITION]
|
|
| 56 |
|
| 57 |
_SOURCE_VERSION = "1.0.0"
|
| 58 |
|
| 59 |
-
|
| 60 |
|
| 61 |
class IndolemNERUGM(datasets.GeneratorBasedBuilder):
|
| 62 |
"""NER UGM comprises 2,343 sentences from news articles, and was constructed at the University of Gajah Mada based on five named entity classes: person, organization, location, time, and quantity; and based on 5-fold cross validation"""
|
|
@@ -64,11 +64,11 @@ class IndolemNERUGM(datasets.GeneratorBasedBuilder):
|
|
| 64 |
label_classes = ["B-PERSON", "B-LOCATION", "B-ORGANIZATION", "B-TIME", "B-QUANTITY", "I-PERSON", "I-LOCATION", "I-ORGANIZATION", "I-TIME", "I-QUANTITY", "O"]
|
| 65 |
|
| 66 |
SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
|
| 67 |
-
|
| 68 |
|
| 69 |
BUILDER_CONFIGS = (
|
| 70 |
[
|
| 71 |
-
|
| 72 |
name="indolem_ner_ugm_fold{fold_number}_source".format(fold_number=i),
|
| 73 |
version=_SOURCE_VERSION,
|
| 74 |
description="indolem_ner_ugm source schema",
|
|
@@ -77,11 +77,11 @@ class IndolemNERUGM(datasets.GeneratorBasedBuilder):
|
|
| 77 |
) for i in range(5)
|
| 78 |
]
|
| 79 |
+ [
|
| 80 |
-
|
| 81 |
-
name="indolem_ner_ugm_fold{fold_number}
|
| 82 |
-
version=
|
| 83 |
description="indolem_ner_ugm Nusantara schema",
|
| 84 |
-
schema="
|
| 85 |
subset_id="indolem_ner_ugm_fold{fold_number}".format(fold_number=i),
|
| 86 |
) for i in range(5)
|
| 87 |
]
|
|
@@ -101,7 +101,7 @@ class IndolemNERUGM(datasets.GeneratorBasedBuilder):
|
|
| 101 |
}
|
| 102 |
)
|
| 103 |
|
| 104 |
-
elif self.config.schema == "
|
| 105 |
features = schemas.seq_label_features(self.label_classes)
|
| 106 |
|
| 107 |
return datasets.DatasetInfo(
|
|
@@ -167,7 +167,7 @@ class IndolemNERUGM(datasets.GeneratorBasedBuilder):
|
|
| 167 |
"tags": row["label"]
|
| 168 |
}
|
| 169 |
yield i, ex
|
| 170 |
-
elif self.config.schema == "
|
| 171 |
for i, row in enumerate(conll_dataset):
|
| 172 |
ex = {
|
| 173 |
"id": str(i),
|
|
|
|
| 2 |
from typing import Dict, List, Tuple
|
| 3 |
|
| 4 |
import datasets
|
| 5 |
+
from seacrowd.utils import schemas
|
| 6 |
+
from seacrowd.utils.common_parser import load_conll_data
|
| 7 |
|
| 8 |
+
from seacrowd.utils.configs import SEACrowdConfig
|
| 9 |
+
from seacrowd.utils.constants import Tasks
|
| 10 |
|
| 11 |
_CITATION = """\
|
| 12 |
@inproceedings{koto-etal-2020-indolem,
|
|
|
|
| 56 |
|
| 57 |
_SOURCE_VERSION = "1.0.0"
|
| 58 |
|
| 59 |
+
_SEACROWD_VERSION = "2024.06.20"
|
| 60 |
|
| 61 |
class IndolemNERUGM(datasets.GeneratorBasedBuilder):
|
| 62 |
"""NER UGM comprises 2,343 sentences from news articles, and was constructed at the University of Gajah Mada based on five named entity classes: person, organization, location, time, and quantity; and based on 5-fold cross validation"""
|
|
|
|
| 64 |
label_classes = ["B-PERSON", "B-LOCATION", "B-ORGANIZATION", "B-TIME", "B-QUANTITY", "I-PERSON", "I-LOCATION", "I-ORGANIZATION", "I-TIME", "I-QUANTITY", "O"]
|
| 65 |
|
| 66 |
SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
|
| 67 |
+
SEACROWD_VERSION = datasets.Version(_SEACROWD_VERSION)
|
| 68 |
|
| 69 |
BUILDER_CONFIGS = (
|
| 70 |
[
|
| 71 |
+
SEACrowdConfig(
|
| 72 |
name="indolem_ner_ugm_fold{fold_number}_source".format(fold_number=i),
|
| 73 |
version=_SOURCE_VERSION,
|
| 74 |
description="indolem_ner_ugm source schema",
|
|
|
|
| 77 |
) for i in range(5)
|
| 78 |
]
|
| 79 |
+ [
|
| 80 |
+
SEACrowdConfig(
|
| 81 |
+
name="indolem_ner_ugm_fold{fold_number}_seacrowd_seq_label".format(fold_number=i),
|
| 82 |
+
version=_SEACROWD_VERSION,
|
| 83 |
description="indolem_ner_ugm Nusantara schema",
|
| 84 |
+
schema="seacrowd_seq_label",
|
| 85 |
subset_id="indolem_ner_ugm_fold{fold_number}".format(fold_number=i),
|
| 86 |
) for i in range(5)
|
| 87 |
]
|
|
|
|
| 101 |
}
|
| 102 |
)
|
| 103 |
|
| 104 |
+
elif self.config.schema == "seacrowd_seq_label":
|
| 105 |
features = schemas.seq_label_features(self.label_classes)
|
| 106 |
|
| 107 |
return datasets.DatasetInfo(
|
|
|
|
| 167 |
"tags": row["label"]
|
| 168 |
}
|
| 169 |
yield i, ex
|
| 170 |
+
elif self.config.schema == "seacrowd_seq_label":
|
| 171 |
for i, row in enumerate(conll_dataset):
|
| 172 |
ex = {
|
| 173 |
"id": str(i),
|