parquet-converter commited on
Commit
fe788ee
1 Parent(s): 91fa821

Update parquet files

Browse files
ccnews_split.py DELETED
@@ -1,148 +0,0 @@
1
- # coding=utf-8
2
- # Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
-
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
- import tarfile
22
- from fnmatch import fnmatch
23
-
24
- import datasets
25
-
26
- def custom_iter_archive(path_or_buf, _filter=lambda x: True):
27
- def _iter_archive(f):
28
- stream = tarfile.open(fileobj=f, mode="r|*")
29
- for i, tarinfo in enumerate(stream):
30
- if not _filter(i):
31
- continue
32
- file_path = tarinfo.name
33
- if not tarinfo.isreg():
34
- continue
35
- if file_path is None:
36
- continue
37
- if os.path.basename(file_path).startswith(".") or os.path.basename(file_path).startswith("__"):
38
- # skipping hidden files
39
- continue
40
- file_obj = stream.extractfile(tarinfo)
41
- yield file_path, file_obj
42
- stream.members = []
43
- del stream
44
-
45
- if hasattr(path_or_buf, "read"):
46
- yield from _iter_archive(path_or_buf)
47
- else:
48
- with open(path_or_buf, "rb") as f:
49
- yield from _iter_archive(f)
50
-
51
- logger = datasets.logging.get_logger(__name__)
52
-
53
-
54
- _DESCRIPTION = """\
55
- CC-News containing news articles from news sites all over the world \
56
- The data is available on AWS S3 in the Common Crawl bucket at /crawl-data/CC-NEWS/. \
57
- This version of the dataset has 708241 articles. It represents a small portion of English \
58
- language subset of the CC-News dataset created using news-please(Hamborg et al.,2017) to \
59
- collect and extract English language portion of CC-News.
60
- """
61
-
62
- _CITATION = """\
63
- @InProceedings{Hamborg2017,
64
- author = {Hamborg, Felix and Meuschke, Norman and Breitinger, Corinna and Gipp, Bela},
65
- title = {news-please: A Generic News Crawler and Extractor},
66
- year = {2017},
67
- booktitle = {Proceedings of the 15th International Symposium of Information Science},
68
- location = {Berlin},
69
- doi = {10.5281/zenodo.4120316},
70
- pages = {218--223},
71
- month = {March}
72
- }
73
- """
74
- _PROJECT_URL = "https://commoncrawl.org/2016/10/news-dataset-available/"
75
- _DOWNLOAD_URL = "https://storage.googleapis.com/huggingface-nlp/datasets/cc_news/cc_news.tar.gz"
76
-
77
-
78
- class CCNewsConfig(datasets.BuilderConfig):
79
- """BuilderConfig for CCNews."""
80
-
81
- def __init__(self, **kwargs):
82
- """BuilderConfig for CCNews.
83
- Args:
84
- **kwargs: keyword arguments forwarded to super.
85
- """
86
- super(CCNewsConfig, self).__init__(version=datasets.Version("1.0.0", ""), **kwargs)
87
-
88
-
89
- class CCNews(datasets.GeneratorBasedBuilder):
90
- """CC-News dataset."""
91
-
92
- BUILDER_CONFIGS = [
93
- CCNewsConfig(
94
- name="plain_text",
95
- description="Plain text",
96
- ),
97
- CCNewsConfig(
98
- name="plain_text_sentences",
99
- description="Plain text (sentence level)",
100
- )
101
- ]
102
-
103
- def _info(self):
104
- return datasets.DatasetInfo(
105
- description=_DESCRIPTION,
106
- features=datasets.Features(
107
- {
108
- "text": datasets.Value("string"),
109
- }
110
- ),
111
- supervised_keys=None,
112
- homepage=_PROJECT_URL,
113
- citation=_CITATION,
114
- )
115
-
116
- def _split_generators(self, dl_manager):
117
- archive = dl_manager.download(_DOWNLOAD_URL)
118
-
119
- train_filter = lambda x : (x%10) < 8
120
- val_filter = lambda x: (x%10) == 8
121
- test_filter = lambda x: (x%10) == 9
122
-
123
- level = "doc" if self.config.name == "plain_text" else "sentence"
124
-
125
- return [
126
- datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"files": custom_iter_archive(archive, train_filter), "level": level}),
127
- datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"files": custom_iter_archive(archive, val_filter), "level": level}),
128
- datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"files": custom_iter_archive(archive, test_filter), "level": level}),
129
- ]
130
-
131
- def _generate_examples(self, files, level):
132
- id_ = 0
133
- for article_file_path, f in files:
134
- if fnmatch(os.path.basename(article_file_path), "*.json"):
135
- article = json.load(f)
136
- if level == "sentence":
137
- full_article = article["maintext"].strip() if article["maintext"] is not None else ""
138
- doc_dict = {}
139
- for sent in full_article.split("\n"):
140
- doc_dict["text"] = sent
141
- yield id_, doc_dict
142
- id_ += 1
143
- else:
144
- yield id_, {
145
- "text": article["maintext"].strip() if article["maintext"] is not None else "",
146
- }
147
- id_ += 1
148
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dataset_infos.json DELETED
@@ -1 +0,0 @@
1
- {"plain_text": {"description": "CC-News containing news articles from news sites all over the world The data is available on AWS S3 in the Common Crawl bucket at /crawl-data/CC-NEWS/. This version of the dataset has 708241 articles. It represents a small portion of English language subset of the CC-News dataset created using news-please(Hamborg et al.,2017) to collect and extract English language portion of CC-News.\n", "citation": "@InProceedings{Hamborg2017,\n author = {Hamborg, Felix and Meuschke, Norman and Breitinger, Corinna and Gipp, Bela},\n title = {news-please: A Generic News Crawler and Extractor},\n year = {2017},\n booktitle = {Proceedings of the 15th International Symposium of Information Science},\n location = {Berlin},\n doi = {10.5281/zenodo.4120316},\n pages = {218--223},\n month = {March}\n}\n", "homepage": "https://commoncrawl.org/2016/10/news-dataset-available/", "license": "", "features": {"title": {"dtype": "string", "id": null, "_type": "Value"}, "text": {"dtype": "string", "id": null, "_type": "Value"}, "domain": {"dtype": "string", "id": null, "_type": "Value"}, "date": {"dtype": "string", "id": null, "_type": "Value"}, "description": {"dtype": "string", "id": null, "_type": "Value"}, "url": {"dtype": "string", "id": null, "_type": "Value"}, "image_url": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "cc_news", "config_name": "plain_text", "version": {"version_str": "1.0.0", "description": "", "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 1612758128, "num_examples": 566588, "dataset_name": "cc_news"}, "validation": {"name": "validation", "num_bytes": 201224444, "num_examples": 70821, "dataset_name": "cc_news"}, "test": {"name": "test", "num_examples": 70832, "dataset_name": "cc_news", "num_bytes": 202435617}}, "download_checksums": {"https://storage.googleapis.com/huggingface-nlp/datasets/cc_news/cc_news.tar.gz": {"num_bytes": 845131146, "checksum": "1aaf8e5af33e3a73472b58afba48c6a839ebc2dd190c4e0754fc00f8899a9cec"}}, "download_size": 845131146, "post_processing_size": null, "dataset_size": 2016418133, "size_in_bytes": 2861549279}}
 
 
plain_text/ccnews_split-test.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2d3dec7a963515915fba92c7a4c2b8462f4b71a7cc64385a279f6700fbb51362
3
+ size 101143111
plain_text/ccnews_split-train-00000-of-00003.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:69eb8e72019efc2eb64514502f0024e7b6f432bec1b5adccd203963e81c6169b
3
+ size 290825722
plain_text/ccnews_split-train-00001-of-00003.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1ef1560e95e810102c2dc41d2ced09660c6c13e495d43b49bd121acbfeab0962
3
+ size 282035858
plain_text/ccnews_split-train-00002-of-00003.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0b1d0873541187f146b3c2fcf4fedb7fd061821ee907b19f921e403db6cfc65b
3
+ size 206250305
plain_text/ccnews_split-validation.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5e7a13d6742c26935d3467a1c22568bffd4e863792d36225ce7a24650f534c18
3
+ size 100618207
plain_text_sentences/ccnews_split-test.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a6ec6b8687c7c0e3b873f8749825742f2baf966cca7f46f975c872c33cd9bc07
3
+ size 105583428
plain_text_sentences/ccnews_split-train-00000-of-00003.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3c54752af345cf28b66c078c9a2ec1f848976283cb907a1f78e13a6e2b8a8a68
3
+ size 301837680
plain_text_sentences/ccnews_split-train-00001-of-00003.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5cb67eabdaa914cb4d2919b61003110cdab0606de62f76c08d9c39c0acc7066d
3
+ size 295517589
plain_text_sentences/ccnews_split-train-00002-of-00003.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fc452cf069d5a8ec2e74bd6ed6152090b9a970e2cd3440af22b340390f34bd44
3
+ size 230423319
plain_text_sentences/ccnews_split-validation.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:118895f415491845acc4944106ae45e4d09c9a8ab57416926885b165fc62b75a
3
+ size 105037875