Update ner.py
Browse files
ner.py
CHANGED
@@ -15,27 +15,6 @@ LugandaPII is a dataset that includes named entities such as PERSON, ORG, LOCATI
|
|
15 |
The dataset is available in Lum, Kanuri, and Hausa languages, distributed across train, validation, and test splits.
|
16 |
"""
|
17 |
|
18 |
-
# Data directory structure
|
19 |
-
data_directory = """
|
20 |
-
data
|
21 |
-
βββ hau
|
22 |
-
β βββ test.txt
|
23 |
-
β βββ train.txt
|
24 |
-
β βββ val.txt
|
25 |
-
βββ knr
|
26 |
-
β βββ test.txt
|
27 |
-
β βββ train.txt
|
28 |
-
β βββ val.txt
|
29 |
-
βββ lug
|
30 |
-
β βββ test.txt
|
31 |
-
β βββ train.txt
|
32 |
-
β βββ val.txt
|
33 |
-
βββ lum
|
34 |
-
βββ test.txt
|
35 |
-
βββ train.txt
|
36 |
-
βββ val.txt
|
37 |
-
"""
|
38 |
-
|
39 |
_URL = "https://github.com/EricPeter/pii/raw/main/data"
|
40 |
_TRAINING_FILE = "train.txt"
|
41 |
_VAL_FILE = "val.txt"
|
@@ -51,9 +30,8 @@ class Masakhaner(datasets.GeneratorBasedBuilder):
|
|
51 |
BUILDER_CONFIGS = [
|
52 |
LugPIIConfig(name="lug", version=datasets.Version("1.0.0"), description="PII NER dataset for Luganda."),
|
53 |
LugPIIConfig(name="hau", version=datasets.Version("1.0.0"), description="PII NER dataset for Hausa."),
|
54 |
-
LugPIIConfig(name="knr", version=datasets.Version("1.0.0"), description="PII NER dataset for
|
55 |
-
LugPIIConfig(name="lum", version=datasets.Version("1.0.0"), description="PII NER dataset for
|
56 |
-
|
57 |
]
|
58 |
|
59 |
def _info(self):
|
@@ -104,7 +82,7 @@ class Masakhaner(datasets.GeneratorBasedBuilder):
|
|
104 |
)
|
105 |
|
106 |
def _split_generators(self, dl_manager):
|
107 |
-
lang_code = self.config.name # 'lug', 'hau',
|
108 |
urls_to_download = {
|
109 |
"train": f"{_URL}/{lang_code}/{_TRAINING_FILE}",
|
110 |
"val": f"{_URL}/{lang_code}/{_VAL_FILE}",
|
@@ -118,7 +96,6 @@ class Masakhaner(datasets.GeneratorBasedBuilder):
|
|
118 |
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]})
|
119 |
]
|
120 |
|
121 |
-
|
122 |
def _generate_examples(self, filepath):
|
123 |
logger.info("Generating examples from = %s", filepath)
|
124 |
with open(filepath, encoding="utf-8") as f:
|
|
|
15 |
The dataset is available in Lum, Kanuri, and Hausa languages, distributed across train, validation, and test splits.
|
16 |
"""
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
_URL = "https://github.com/EricPeter/pii/raw/main/data"
|
19 |
_TRAINING_FILE = "train.txt"
|
20 |
_VAL_FILE = "val.txt"
|
|
|
30 |
BUILDER_CONFIGS = [
|
31 |
LugPIIConfig(name="lug", version=datasets.Version("1.0.0"), description="PII NER dataset for Luganda."),
|
32 |
LugPIIConfig(name="hau", version=datasets.Version("1.0.0"), description="PII NER dataset for Hausa."),
|
33 |
+
LugPIIConfig(name="knr", version=datasets.Version("1.0.0"), description="PII NER dataset for Kanuri."),
|
34 |
+
LugPIIConfig(name="lum", version=datasets.Version("1.0.0"), description="PII NER dataset for Lum."),
|
|
|
35 |
]
|
36 |
|
37 |
def _info(self):
|
|
|
82 |
)
|
83 |
|
84 |
def _split_generators(self, dl_manager):
|
85 |
+
lang_code = self.config.name # 'lug', 'hau', 'knr', 'lum'
|
86 |
urls_to_download = {
|
87 |
"train": f"{_URL}/{lang_code}/{_TRAINING_FILE}",
|
88 |
"val": f"{_URL}/{lang_code}/{_VAL_FILE}",
|
|
|
96 |
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]})
|
97 |
]
|
98 |
|
|
|
99 |
def _generate_examples(self, filepath):
|
100 |
logger.info("Generating examples from = %s", filepath)
|
101 |
with open(filepath, encoding="utf-8") as f:
|