Files changed (1) hide show
  1. dafand.py +32 -35
dafand.py CHANGED
@@ -4,55 +4,52 @@ import json
4
  logger = datasets.logging.get_logger(__name__)
5
 
6
  _DESCRIPTION = """
7
- MAFAND-DALA is a dataset for low resource african languages majorly in nigeria covering
8
  """
9
 
10
- _URL = "https://raw/githubusercontent.com/Dala-Group-A/dala-religion/main/data/final/"
11
- _TRAINING_FILE = "train.json"
12
 
13
- class DalaConfig(datasets.BuilderCOnfig):
14
- """builder config for dala"""
15
  def __init__(self, **kwargs):
16
- super(DalaConfig, self).__init__(**kwargs)
17
 
18
- class Dala(datasets.GeneratorBaseBuilder):
19
- """dala datasets"""
20
  BUILDER_CONFIGS = [
21
- DalaConfig(name="en-igl", version=datasets.Version("1.0.0"), description="dala english-igala dataset"),
22
- DalaConfig(name="en-edo", version=datasets.Version("1.0.0"), description="dala english-edo dataset"),
23
- DalaConfig(name="en-lng", version=datasets.Version("1.0.0"), description="dala english-lango dataset"),
24
- DalaConfig(name="en-ijw", version=datasets.Version("1.0.0"), description="dala english-ijaw dataset"),
25
- DalaConfig(name="en-its", version=datasets.Version("1.0.0"), description="dala english-itsekiri dataset"),
26
 
27
  ]
28
 
29
  def _info(self):
30
- source, target = self.config.name.split("-")
31
  return datasets.DatasetInfo(
32
  description=_DESCRIPTION,
33
- features=datasets.Features({"translation": datasets.features.Translation(laguages=(source, target))}),
34
- supervised_keys=(source, target),
35
- homepage="https://"
36
  )
37
 
38
  def _split_generators(self, dl_manager):
39
- """ Returns Split Generators """
40
- source, target = self.config.name.split('-')
41
- if target in ['igl', 'edo', 'ijw', 'its', 'lng']:
42
- urls_to_download = {
43
- "train": f"{_URL}{self.config.name}/{_TRAINING_FILE}",
44
- }
45
- downloaded_files = dl_manager.download_and_extract(urls_to_download)
46
- return [
47
- datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={'filepath': downloaded_files["train"]})
48
- ]
49
-
50
-
51
- def _generate_example(self, filepath):
52
- logger.info("generating examples from = %s", filepath)
 
53
  with open(filepath, encoding="utf-8") as f:
54
  idx = 0
55
- for line in f:
56
- src_tgt = json.loads(line)
57
- yield idx, src_tgt
58
- idx += 1
 
4
  logger = datasets.logging.get_logger(__name__)
5
 
6
  _DESCRIPTION = """
7
+
8
  """
9
 
10
+ _URL = "https://raw.githubusercontent.com/Dala-Group-A/etlPipeline/refs/heads/main/datasets/"
11
+ _TRAINING_FILE = "train.json"
12
 
13
+ class DafandConfig(datasets.BuilderConfig):
14
+ """Builder config for dafand"""
15
  def __init__(self, **kwargs):
16
+ super(DafandConfig, self).__init__(**kwargs)
17
 
18
+ class Dafand(datasets.GeneratorBasedBuilder):
19
+ "Dafand Datasets"
20
  BUILDER_CONFIGS = [
21
+ DafandConfig(name="edo_english_bible", version=datasets.Version("1.0.0"), description="Dafand Edo English Bible"),
 
 
 
 
22
 
23
  ]
24
 
25
  def _info(self):
26
+ source, target, _= self.config.name.split('_')
27
  return datasets.DatasetInfo(
28
  description=_DESCRIPTION,
29
+ features=datasets.Features({"translation": datasets.features.Translation(languages=[source, target])}),
30
+ # supervised_keys=(source, target),
31
+ homepage="https://github.com/Dala-Group-A/etlPipeline/",
32
  )
33
 
34
  def _split_generators(self, dl_manager):
35
+ "Returns Split Generators"
36
+ source, target, _ = self.config.name.split("_")
37
+ # if target in ["edo", ]: # come here to update language names found in datasets
38
+ urls_to_download = {
39
+ "train": f"{_URL}{self.config.name}/{_TRAINING_FILE}",
40
+ }
41
+ downloaded_files = dl_manager.download_and_extract(urls_to_download)
42
+ return [
43
+ datasets.SplitGenerator(
44
+ name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}, # ty:ignore[invalid-argument-type]
45
+ )
46
+ ]
47
+
48
+ def _generate_examples(self, filepath): # ty:ignore[invalid-method-override]
49
+ logger.info("Generating examples from = %s", filepath)
50
  with open(filepath, encoding="utf-8") as f:
51
  idx = 0
52
+ src_tgt = json.load(f)
53
+ for line in src_tgt:
54
+ yield idx, line
55
+ idx += 1