EricPeter commited on
Commit
3f15978
β€’
1 Parent(s): 23ca1ed

Update ner.py

Browse files
Files changed (1) hide show
  1. ner.py +3 -26
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 Hausa."),
55
- LugPIIConfig(name="lum", version=datasets.Version("1.0.0"), description="PII NER dataset for Hausa."),
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', etc.
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: