Update files from the datasets library (from 1.16.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.16.0
- README.md +1 -0
- 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 |
-
|
95 |
|
96 |
return [
|
97 |
-
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"
|
98 |
]
|
99 |
|
100 |
-
def _generate_examples(self,
|
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
|
107 |
-
|
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 "",
|