system HF staff commited on
Commit
24e7c0c
1 Parent(s): 3510eb6

Update files from the datasets library (from 1.16.0)

Browse files

Release notes: https://github.com/huggingface/datasets/releases/tag/1.16.0

Files changed (2) hide show
  1. README.md +1 -0
  2. cc_news.py +6 -10
README.md CHANGED
@@ -1,4 +1,5 @@
1
  ---
 
2
  annotations_creators:
3
  - no-annotation
4
  language_creators:
 
1
  ---
2
+ pretty_name: CC-News
3
  annotations_creators:
4
  - no-annotation
5
  language_creators:
cc_news.py CHANGED
@@ -16,9 +16,9 @@
16
  # Lint as: python3
17
  """The CC-News dataset is based on Common Crawl News Dataset by Sebastian Nagel"""
18
 
19
- import glob
20
  import json
21
  import os
 
22
 
23
  import datasets
24
 
@@ -91,20 +91,16 @@ class CCNews(datasets.GeneratorBasedBuilder):
91
  )
92
 
93
  def _split_generators(self, dl_manager):
94
- arch_path = dl_manager.download_and_extract(_DOWNLOAD_URL)
95
 
96
  return [
97
- datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"directory": arch_path}),
98
  ]
99
 
100
- def _generate_examples(self, directory):
101
- logger.info("CC-News dataset: generating examples from = %s", directory)
102
- glob_target = os.path.join(directory, "**/*.json")
103
- article_files = glob.glob(glob_target, recursive=True)
104
- article_files = sorted(article_files)
105
  id_ = 0
106
- for article_file_path in article_files:
107
- with open(article_file_path, mode="r", encoding="utf-8") as f:
108
  article = json.load(f)
109
  yield id_, {
110
  "title": article["title"].strip() if article["title"] is not None else "",
 
16
  # Lint as: python3
17
  """The CC-News dataset is based on Common Crawl News Dataset by Sebastian Nagel"""
18
 
 
19
  import json
20
  import os
21
+ from fnmatch import fnmatch
22
 
23
  import datasets
24
 
 
91
  )
92
 
93
  def _split_generators(self, dl_manager):
94
+ archive = dl_manager.download(_DOWNLOAD_URL)
95
 
96
  return [
97
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"files": dl_manager.iter_archive(archive)}),
98
  ]
99
 
100
+ def _generate_examples(self, files):
 
 
 
 
101
  id_ = 0
102
+ for article_file_path, f in files:
103
+ if fnmatch(os.path.basename(article_file_path), "*.json"):
104
  article = json.load(f)
105
  yield id_, {
106
  "title": article["title"].strip() if article["title"] is not None else "",