khalidalt commited on
Commit
5b60e55
1 Parent(s): 3db59d9

Update HuffPost.py

Browse files
Files changed (1) hide show
  1. HuffPost.py +10 -15
HuffPost.py CHANGED
@@ -51,8 +51,7 @@ _HOMEPAGE = "https://www.kaggle.com/datasets/rmisra/news-category-dataset"
51
 
52
  _LICENSE = "CC0: Public Domain"
53
 
54
- _URLS = { "train":"https://huggingface.co/datasets/khalidalt/HuffPost/resolve/main/News_Category_Dataset_v2.json",
55
- }
56
 
57
 
58
 
@@ -73,12 +72,13 @@ class HuffPost(datasets.GeneratorBasedBuilder):
73
  # data = datasets.load_dataset('my_dataset', 'first_domain')
74
  # data = datasets.load_dataset('my_dataset', 'second_domain')
75
  BUILDER_CONFIGS = [
76
- datasets.BuilderConfig(name="text", version=VERSION, description="text of the data"),
77
  ]
78
-
 
79
 
80
  def _info(self):
81
-
82
  features = datasets.Features(
83
  {
84
  "category": datasets.Value("string"),
@@ -86,7 +86,7 @@ class HuffPost(datasets.GeneratorBasedBuilder):
86
  "authors": datasets.Value("string"),
87
  "link": datasets.Value("string"),
88
  "short_description": datasets.Value("string"),
89
- "date": dataset.Value("string"),
90
  # These are the features of your dataset like images, labels ...
91
  }
92
  )
@@ -114,18 +114,13 @@ class HuffPost(datasets.GeneratorBasedBuilder):
114
  # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
115
  # It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
116
  # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
117
- urls = _URLS[self.config.name]
118
- data_dir = dl_manager.download_and_extract(urls)
119
  return [
120
  datasets.SplitGenerator(
121
  name=datasets.Split.TRAIN,
122
- # These kwargs will be passed to _generate_examples
123
- gen_kwargs={
124
- "filepath": os.path.join(data_dir, "train.json"),
125
- "split": "train",
126
- },
127
  ),
128
-
129
  ]
130
 
131
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
@@ -143,5 +138,5 @@ class HuffPost(datasets.GeneratorBasedBuilder):
143
  "authors": data["authors"],
144
  "link": data["link"],
145
  "short_description": data["short_description"],
146
- "date": data["date"],
147
  }
 
51
 
52
  _LICENSE = "CC0: Public Domain"
53
 
54
+ _URLS = "https://huggingface.co/datasets/khalidalt/HuffPost/resolve/main/News_Category_Dataset_v2.json"
 
55
 
56
 
57
 
 
72
  # data = datasets.load_dataset('my_dataset', 'first_domain')
73
  # data = datasets.load_dataset('my_dataset', 'second_domain')
74
  BUILDER_CONFIGS = [
75
+ datasets.BuilderConfig(name="default", version=VERSION, description="Default config"),
76
  ]
77
+
78
+ DEFAULT_CONFIG_NAME = "default"
79
 
80
  def _info(self):
81
+
82
  features = datasets.Features(
83
  {
84
  "category": datasets.Value("string"),
 
86
  "authors": datasets.Value("string"),
87
  "link": datasets.Value("string"),
88
  "short_description": datasets.Value("string"),
89
+ #"date": dataset.Value("string"),
90
  # These are the features of your dataset like images, labels ...
91
  }
92
  )
 
114
  # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
115
  # It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
116
  # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
117
+
118
+ data_dir = dl_manager.download_and_extract(_URLS)
119
  return [
120
  datasets.SplitGenerator(
121
  name=datasets.Split.TRAIN,
122
+ gen_kwargs={"filepath": data_dir},
 
 
 
 
123
  ),
 
124
  ]
125
 
126
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
 
138
  "authors": data["authors"],
139
  "link": data["link"],
140
  "short_description": data["short_description"],
141
+ #"date": data["date"],
142
  }