holylovenia
commited on
Commit
•
485199e
1
Parent(s):
43f9f85
Upload nerp.py with huggingface_hub
Browse files
nerp.py
CHANGED
@@ -3,15 +3,15 @@ from typing import List
|
|
3 |
|
4 |
import datasets
|
5 |
|
6 |
-
from
|
7 |
-
from
|
8 |
-
from
|
9 |
-
from
|
10 |
DEFAULT_SOURCE_VIEW_NAME, Tasks)
|
11 |
|
12 |
_DATASETNAME = "nerp"
|
13 |
_SOURCE_VIEW_NAME = DEFAULT_SOURCE_VIEW_NAME
|
14 |
-
_UNIFIED_VIEW_NAME =
|
15 |
|
16 |
_LANGUAGES = ["ind"]
|
17 |
_LOCAL = False
|
@@ -49,7 +49,7 @@ _URLs = {
|
|
49 |
_SUPPORTED_TASKS = [Tasks.NAMED_ENTITY_RECOGNITION]
|
50 |
|
51 |
_SOURCE_VERSION = "1.0.0"
|
52 |
-
|
53 |
|
54 |
|
55 |
class NerpDataset(datasets.GeneratorBasedBuilder):
|
@@ -58,18 +58,18 @@ class NerpDataset(datasets.GeneratorBasedBuilder):
|
|
58 |
label_classes = ["B-PPL", "B-PLC", "B-EVT", "B-IND", "B-FNB", "I-PPL", "I-PLC", "I-EVT", "I-IND", "I-FNB", "O"]
|
59 |
|
60 |
BUILDER_CONFIGS = [
|
61 |
-
|
62 |
name="nerp_source",
|
63 |
version=datasets.Version(_SOURCE_VERSION),
|
64 |
description="NERP source schema",
|
65 |
schema="source",
|
66 |
subset_id="nerp",
|
67 |
),
|
68 |
-
|
69 |
-
name="
|
70 |
-
version=datasets.Version(
|
71 |
description="NERP Nusantara schema",
|
72 |
-
schema="
|
73 |
subset_id="nerp",
|
74 |
),
|
75 |
]
|
@@ -79,7 +79,7 @@ class NerpDataset(datasets.GeneratorBasedBuilder):
|
|
79 |
def _info(self):
|
80 |
if self.config.schema == "source":
|
81 |
features = datasets.Features({"index": datasets.Value("string"), "tokens": [datasets.Value("string")], "ner_tag": [datasets.Value("string")]})
|
82 |
-
elif self.config.schema == "
|
83 |
features = schemas.seq_label_features(self.label_classes)
|
84 |
|
85 |
return datasets.DatasetInfo(
|
@@ -122,7 +122,7 @@ class NerpDataset(datasets.GeneratorBasedBuilder):
|
|
122 |
for i, row in enumerate(conll_dataset):
|
123 |
ex = {"index": str(i), "tokens": row["sentence"], "ner_tag": row["label"]}
|
124 |
yield i, ex
|
125 |
-
elif self.config.schema == "
|
126 |
for i, row in enumerate(conll_dataset):
|
127 |
ex = {"id": str(i), "tokens": row["sentence"], "labels": row["label"]}
|
128 |
yield i, ex
|
|
|
3 |
|
4 |
import datasets
|
5 |
|
6 |
+
from seacrowd.utils import schemas
|
7 |
+
from seacrowd.utils.common_parser import load_conll_data
|
8 |
+
from seacrowd.utils.configs import SEACrowdConfig
|
9 |
+
from seacrowd.utils.constants import (DEFAULT_SEACROWD_VIEW_NAME,
|
10 |
DEFAULT_SOURCE_VIEW_NAME, Tasks)
|
11 |
|
12 |
_DATASETNAME = "nerp"
|
13 |
_SOURCE_VIEW_NAME = DEFAULT_SOURCE_VIEW_NAME
|
14 |
+
_UNIFIED_VIEW_NAME = DEFAULT_SEACROWD_VIEW_NAME
|
15 |
|
16 |
_LANGUAGES = ["ind"]
|
17 |
_LOCAL = False
|
|
|
49 |
_SUPPORTED_TASKS = [Tasks.NAMED_ENTITY_RECOGNITION]
|
50 |
|
51 |
_SOURCE_VERSION = "1.0.0"
|
52 |
+
_SEACROWD_VERSION = "2024.06.20"
|
53 |
|
54 |
|
55 |
class NerpDataset(datasets.GeneratorBasedBuilder):
|
|
|
58 |
label_classes = ["B-PPL", "B-PLC", "B-EVT", "B-IND", "B-FNB", "I-PPL", "I-PLC", "I-EVT", "I-IND", "I-FNB", "O"]
|
59 |
|
60 |
BUILDER_CONFIGS = [
|
61 |
+
SEACrowdConfig(
|
62 |
name="nerp_source",
|
63 |
version=datasets.Version(_SOURCE_VERSION),
|
64 |
description="NERP source schema",
|
65 |
schema="source",
|
66 |
subset_id="nerp",
|
67 |
),
|
68 |
+
SEACrowdConfig(
|
69 |
+
name="nerp_seacrowd_seq_label",
|
70 |
+
version=datasets.Version(_SEACROWD_VERSION),
|
71 |
description="NERP Nusantara schema",
|
72 |
+
schema="seacrowd_seq_label",
|
73 |
subset_id="nerp",
|
74 |
),
|
75 |
]
|
|
|
79 |
def _info(self):
|
80 |
if self.config.schema == "source":
|
81 |
features = datasets.Features({"index": datasets.Value("string"), "tokens": [datasets.Value("string")], "ner_tag": [datasets.Value("string")]})
|
82 |
+
elif self.config.schema == "seacrowd_seq_label":
|
83 |
features = schemas.seq_label_features(self.label_classes)
|
84 |
|
85 |
return datasets.DatasetInfo(
|
|
|
122 |
for i, row in enumerate(conll_dataset):
|
123 |
ex = {"index": str(i), "tokens": row["sentence"], "ner_tag": row["label"]}
|
124 |
yield i, ex
|
125 |
+
elif self.config.schema == "seacrowd_seq_label":
|
126 |
for i, row in enumerate(conll_dataset):
|
127 |
ex = {"id": str(i), "tokens": row["sentence"], "labels": row["label"]}
|
128 |
yield i, ex
|