khalidalt commited on
Commit
9cc1428
1 Parent(s): 1092b34

Update ultimate_arabic_news.py

Browse files
Files changed (1) hide show
  1. ultimate_arabic_news.py +21 -22
ultimate_arabic_news.py CHANGED
@@ -8,8 +8,8 @@ _HOMEPAGE = "TODO"
8
 
9
  _LICENSE = "TODO"
10
 
11
- _URL = {"news":"https://huggingface.co/datasets/khalidalt/ultimate_arabic_news/blob/main/UltimateArabic.csv"
12
- "news_preproces":"https://huggingface.co/datasets/khalidalt/ultimate_arabic_news/blob/main/UltimateArabicPrePros.csv"}
13
 
14
 
15
  class UAN_Config(datasets.BuilderConfig):
@@ -27,7 +27,7 @@ class UAN_Config(datasets.BuilderConfig):
27
  class Ultimate_Arabic_News(datasets.GeneratorBasedBuilder):
28
  VERSION = datasets.Version("1.1.0")
29
  BUILDER_CONFIGS = [
30
- TydiqaConfig(
31
  name="UltimateArabic",
32
  description=textwrap.dedent(
33
  """\
@@ -36,7 +36,7 @@ class Ultimate_Arabic_News(datasets.GeneratorBasedBuilder):
36
  language processing tasks such as text classification."""
37
  ),
38
  ),
39
- TydiqaConfig(
40
  name="UltimateArabicPrePros",
41
  description=textwrap.dedent(
42
  """UltimateArabicPrePros: It is a file that contains the data mentioned in the first file, but after pre-processing, where
@@ -66,7 +66,7 @@ class Ultimate_Arabic_News(datasets.GeneratorBasedBuilder):
66
  # builder.as_dataset.
67
  supervised_keys=None,
68
  # Homepage of the dataset for documentation
69
- homepage="https://github.com/google-research-datasets/tydiqa",
70
  citation=_CITATION,
71
  )
72
 
@@ -76,31 +76,30 @@ class Ultimate_Arabic_News(datasets.GeneratorBasedBuilder):
76
  # TODO(tydiqa): Downloads the data and defines the splits
77
  # dl_manager is a datasets.download.DownloadManager that can be used to
78
  # download and extract URLs
79
- primary_downloaded = dl_manager.download_and_extract(_PRIMARY_URLS)
80
- secondary_downloaded = dl_manager.download_and_extract(_SECONDARY_URLS)
81
- if self.config.name == "primary_task":
82
  return [
83
  datasets.SplitGenerator(
84
  name=datasets.Split.TRAIN,
85
  # These kwargs will be passed to _generate_examples
86
- gen_kwargs={"filepath": primary_downloaded["train"]},
87
- ),
88
- datasets.SplitGenerator(
89
- name=datasets.Split.VALIDATION,
90
- # These kwargs will be passed to _generate_examples
91
- gen_kwargs={"filepath": primary_downloaded["dev"]},
92
  ),
93
  ]
94
- elif self.config.name == "secondary_task":
95
  return [
96
  datasets.SplitGenerator(
97
  name=datasets.Split.TRAIN,
98
  # These kwargs will be passed to _generate_examples
99
- gen_kwargs={"filepath": secondary_downloaded["train"]},
100
- ),
101
- datasets.SplitGenerator(
102
- name=datasets.Split.VALIDATION,
103
- # These kwargs will be passed to _generate_examples
104
- gen_kwargs={"filepath": secondary_downloaded["dev"]},
105
  ),
106
- ]
 
 
 
 
 
 
 
 
 
 
8
 
9
  _LICENSE = "TODO"
10
 
11
+ _URL = {"UltimateArabic":"https://huggingface.co/datasets/khalidalt/ultimate_arabic_news/blob/main/UltimateArabic.csv"
12
+ "UltimateArabicPrePros":"https://huggingface.co/datasets/khalidalt/ultimate_arabic_news/blob/main/UltimateArabicPrePros.csv"}
13
 
14
 
15
  class UAN_Config(datasets.BuilderConfig):
 
27
  class Ultimate_Arabic_News(datasets.GeneratorBasedBuilder):
28
  VERSION = datasets.Version("1.1.0")
29
  BUILDER_CONFIGS = [
30
+ UAN_Config(
31
  name="UltimateArabic",
32
  description=textwrap.dedent(
33
  """\
 
36
  language processing tasks such as text classification."""
37
  ),
38
  ),
39
+ UAN_Config(
40
  name="UltimateArabicPrePros",
41
  description=textwrap.dedent(
42
  """UltimateArabicPrePros: It is a file that contains the data mentioned in the first file, but after pre-processing, where
 
66
  # builder.as_dataset.
67
  supervised_keys=None,
68
  # Homepage of the dataset for documentation
69
+ homepage="https://data.mendeley.com/datasets/jz56k5wxz7/1",
70
  citation=_CITATION,
71
  )
72
 
 
76
  # TODO(tydiqa): Downloads the data and defines the splits
77
  # dl_manager is a datasets.download.DownloadManager that can be used to
78
  # download and extract URLs
79
+ UltAr_downloaded = dl_manager.download_and_extract(_URL['UltimateArabic'])
80
+ UltArPre_downloaded = dl_manager.download_and_extract(_URL['UltimateArabicPrePros'])
81
+ if self.config.name == "UltimateArabic":
82
  return [
83
  datasets.SplitGenerator(
84
  name=datasets.Split.TRAIN,
85
  # These kwargs will be passed to _generate_examples
86
+ gen_kwargs={"filepath": UltAr_downloaded["train"]},
 
 
 
 
 
87
  ),
88
  ]
89
+ elif self.config.name == "UltimateArabicPrePros":
90
  return [
91
  datasets.SplitGenerator(
92
  name=datasets.Split.TRAIN,
93
  # These kwargs will be passed to _generate_examples
94
+ gen_kwargs={"filepath": UltArPre_downloaded["train"]},
 
 
 
 
 
95
  ),
96
+
97
+ ]
98
+
99
+ def _generate_examples(self, csv_file):
100
+ with open(csv_file, encoding="utf-8") as f:
101
+ data = csv.DictReader(f)
102
+ for row, item in enumerate(data):
103
+ yield row, {"text": item['text'],"label": item['label']}
104
+
105
+