system HF staff commited on
Commit
d993da1
0 Parent(s):

Update files from the datasets library (from 1.0.0)

Browse files

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

.gitattributes ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
5
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.model filter=lfs diff=lfs merge=lfs -text
12
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
13
+ *.onnx filter=lfs diff=lfs merge=lfs -text
14
+ *.ot filter=lfs diff=lfs merge=lfs -text
15
+ *.parquet filter=lfs diff=lfs merge=lfs -text
16
+ *.pb filter=lfs diff=lfs merge=lfs -text
17
+ *.pt filter=lfs diff=lfs merge=lfs -text
18
+ *.pth filter=lfs diff=lfs merge=lfs -text
19
+ *.rar filter=lfs diff=lfs merge=lfs -text
20
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
21
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
22
+ *.tflite filter=lfs diff=lfs merge=lfs -text
23
+ *.tgz filter=lfs diff=lfs merge=lfs -text
24
+ *.xz filter=lfs diff=lfs merge=lfs -text
25
+ *.zip filter=lfs diff=lfs merge=lfs -text
26
+ *.zstandard filter=lfs diff=lfs merge=lfs -text
27
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
dataset_infos.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"byarticle": {"description": "Hyperpartisan News Detection was a dataset created for PAN @ SemEval 2019 Task 4.\nGiven a news article text, decide whether it follows a hyperpartisan argumentation, i.e., whether it exhibits blind, prejudiced, or unreasoning allegiance to one party, faction, cause, or person.\n\nThere are 2 parts:\n- byarticle: Labeled through crowdsourcing on an article basis. The data contains only articles for which a consensus among the crowdsourcing workers existed.\n- bypublisher: Labeled by the overall bias of the publisher as provided by BuzzFeed journalists or MediaBiasFactCheck.com.\n", "citation": "@article{kiesel2019data,\n title={Data for pan at semeval 2019 task 4: Hyperpartisan news detection},\n author={Kiesel, Johannes and Mestre, Maria and Shukla, Rishabh and Vincent, Emmanuel and Corney, David and Adineh, Payam and Stein, Benno and Potthast, Martin},\n year={2019}\n}\n", "homepage": "https://pan.webis.de/semeval19/semeval19-web/", "license": "", "features": {"text": {"dtype": "string", "id": null, "_type": "Value"}, "title": {"dtype": "string", "id": null, "_type": "Value"}, "hyperpartisan": {"dtype": "bool", "id": null, "_type": "Value"}, "url": {"dtype": "string", "id": null, "_type": "Value"}, "published_at": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": {"features": null, "resources_checksums": {"train": {}}}, "supervised_keys": {"input": "text", "output": "label"}, "builder_name": "hyperpartisan_news_detection", "config_name": "byarticle", "version": {"version_str": "1.0.0", "description": "Version Training and validation v1", "datasets_version_to_prepare": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 2803943, "num_examples": 645, "dataset_name": "hyperpartisan_news_detection"}}, "download_checksums": {"https://zenodo.org/record/1489920/files/articles-training-byarticle-20181122.zip?download=1": {"num_bytes": 971841, "checksum": "62b4a71275ef2724faddc74d6ff3d782ee9898c732cd66119c7976f6f5168990"}, "https://zenodo.org/record/1489920/files/ground-truth-training-byarticle-20181122.zip?download=1": {"num_bytes": 28511, "checksum": "0c02f4c33317287758e6fbbc976cbfd7a0978923899ddf30cb9dd2cd740af43c"}}, "download_size": 1000352, "post_processing_size": 0, "dataset_size": 2803943, "size_in_bytes": 3804295}, "bypublisher": {"description": "Hyperpartisan News Detection was a dataset created for PAN @ SemEval 2019 Task 4.\nGiven a news article text, decide whether it follows a hyperpartisan argumentation, i.e., whether it exhibits blind, prejudiced, or unreasoning allegiance to one party, faction, cause, or person.\n\nThere are 2 parts:\n- byarticle: Labeled through crowdsourcing on an article basis. The data contains only articles for which a consensus among the crowdsourcing workers existed.\n- bypublisher: Labeled by the overall bias of the publisher as provided by BuzzFeed journalists or MediaBiasFactCheck.com.\n", "citation": "@article{kiesel2019data,\n title={Data for pan at semeval 2019 task 4: Hyperpartisan news detection},\n author={Kiesel, Johannes and Mestre, Maria and Shukla, Rishabh and Vincent, Emmanuel and Corney, David and Adineh, Payam and Stein, Benno and Potthast, Martin},\n year={2019}\n}\n", "homepage": "https://pan.webis.de/semeval19/semeval19-web/", "license": "", "features": {"text": {"dtype": "string", "id": null, "_type": "Value"}, "title": {"dtype": "string", "id": null, "_type": "Value"}, "hyperpartisan": {"dtype": "bool", "id": null, "_type": "Value"}, "url": {"dtype": "string", "id": null, "_type": "Value"}, "published_at": {"dtype": "string", "id": null, "_type": "Value"}, "bias": {"num_classes": 5, "names": ["right", "right-center", "least", "left-center", "left"], "names_file": null, "id": null, "_type": "ClassLabel"}}, "post_processed": {"features": null, "resources_checksums": {"train": {}, "validation": {}}}, "supervised_keys": {"input": "text", "output": "label"}, "builder_name": "hyperpartisan_news_detection", "config_name": "bypublisher", "version": {"version_str": "1.0.0", "description": "Version Training and validation v1", "datasets_version_to_prepare": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 2805711609, "num_examples": 600000, "dataset_name": "hyperpartisan_news_detection"}, "validation": {"name": "validation", "num_bytes": 2805711609, "num_examples": 600000, "dataset_name": "hyperpartisan_news_detection"}}, "download_checksums": {"https://zenodo.org/record/1489920/files/articles-training-bypublisher-20181122.zip?download=1": {"num_bytes": 980769009, "checksum": "e5816b0c9fecd1a38f6cba8eb4f6f77d04637b5c6209e714b7ab32dc3bc24e28"}, "https://zenodo.org/record/1489920/files/ground-truth-training-bypublisher-20181122.zip?download=1": {"num_bytes": 22426411, "checksum": "f1c0494af86ff1e961479a63d432d649ccda875d302888f4d080dbec0382b1ef"}}, "download_size": 1003195420, "post_processing_size": 0, "dataset_size": 5611423218, "size_in_bytes": 6614618638}}
dummy/byarticle/1.0.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3d4cfb152137718e874609af37286a8294b3567cad8596f9fa261409f607e0c5
3
+ size 2701
dummy/bypublisher/1.0.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f5f0d7b0938e500d03afeb9131dfc48af67b37cc0c7f66317df08d08999a732c
3
+ size 5337
hyperpartisan_news_detection.py ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """Hyperpartisan News Detection"""
18
+
19
+ from __future__ import absolute_import, division, print_function
20
+
21
+ import os
22
+ import textwrap
23
+ import xml.etree.ElementTree as ET
24
+
25
+ import datasets
26
+
27
+
28
+ _CITATION = """\
29
+ @article{kiesel2019data,
30
+ title={Data for pan at semeval 2019 task 4: Hyperpartisan news detection},
31
+ author={Kiesel, Johannes and Mestre, Maria and Shukla, Rishabh and Vincent, Emmanuel and Corney, David and Adineh, Payam and Stein, Benno and Potthast, Martin},
32
+ year={2019}
33
+ }
34
+ """
35
+
36
+ _DESCRIPTION = """\
37
+ Hyperpartisan News Detection was a dataset created for PAN @ SemEval 2019 Task 4.
38
+ Given a news article text, decide whether it follows a hyperpartisan argumentation, i.e., whether it exhibits blind, prejudiced, or unreasoning allegiance to one party, faction, cause, or person.
39
+
40
+ There are 2 parts:
41
+ - byarticle: Labeled through crowdsourcing on an article basis. The data contains only articles for which a consensus among the crowdsourcing workers existed.
42
+ - bypublisher: Labeled by the overall bias of the publisher as provided by BuzzFeed journalists or MediaBiasFactCheck.com.
43
+ """
44
+ _URL_BASE = "https://zenodo.org/record/1489920/files/"
45
+
46
+
47
+ class HyperpartisanNewsDetection(datasets.GeneratorBasedBuilder):
48
+ """Hyperpartisan News Detection Dataset."""
49
+
50
+ VERSION = datasets.Version("1.0.0")
51
+ BUILDER_CONFIGS = [
52
+ datasets.BuilderConfig(
53
+ name="byarticle",
54
+ version=datasets.Version("1.0.0", "Version Training and validation v1"),
55
+ description=textwrap.dedent(
56
+ """
57
+ This part of the data (filename contains "byarticle") is labeled through crowdsourcing on an article basis.
58
+ The data contains only articles for which a consensus among the crowdsourcing workers existed. It contains
59
+ a total of 645 articles. Of these, 238 (37%) are hyperpartisan and 407 (63%) are not, We will use a similar
60
+ (but balanced!) test set. Again, none of the publishers in this set will occur in the test set.
61
+ """
62
+ ),
63
+ ),
64
+ datasets.BuilderConfig(
65
+ name="bypublisher",
66
+ version=datasets.Version("1.0.0", "Version Training and validation v1"),
67
+ description=textwrap.dedent(
68
+ """
69
+ This part of the data (filename contains "bypublisher") is labeled by the overall bias of the publisher as provided
70
+ by BuzzFeed journalists or MediaBiasFactCheck.com. It contains a total of 750,000 articles, half of which (375,000)
71
+ are hyperpartisan and half of which are not. Half of the articles that are hyperpartisan (187,500) are on the left side
72
+ of the political spectrum, half are on the right side. This data is split into a training set (80%, 600,000 articles) and
73
+ a validation set (20%, 150,000 articles), where no publisher that occurs in the training set also occurs in the validation
74
+ set. Similarly, none of the publishers in those sets will occur in the test set.
75
+ """
76
+ ),
77
+ ),
78
+ ]
79
+
80
+ def _info(self):
81
+ features = {
82
+ "text": datasets.Value("string"),
83
+ "title": datasets.Value("string"),
84
+ "hyperpartisan": datasets.Value("bool"),
85
+ "url": datasets.Value("string"),
86
+ "published_at": datasets.Value("string"),
87
+ }
88
+
89
+ if self.config.name == "bypublisher":
90
+ # Bias is only included in the bypublisher config
91
+ features["bias"] = datasets.ClassLabel(names=["right", "right-center", "least", "left-center", "left"])
92
+
93
+ return datasets.DatasetInfo(
94
+ description=_DESCRIPTION,
95
+ features=datasets.Features(features),
96
+ supervised_keys=("text", "label"),
97
+ homepage="https://pan.webis.de/semeval19/semeval19-web/",
98
+ citation=_CITATION,
99
+ )
100
+
101
+ def _split_generators(self, dl_manager):
102
+ """Returns SplitGenerators."""
103
+ urls = {
104
+ datasets.Split.TRAIN: {
105
+ "articles_file": _URL_BASE + "articles-training-" + self.config.name + "-20181122.zip?download=1",
106
+ "labels_file": _URL_BASE + "ground-truth-training-" + self.config.name + "-20181122.zip?download=1",
107
+ },
108
+ }
109
+ if self.config.name == "bypublisher":
110
+ urls[datasets.Split.VALIDATION] = {
111
+ "articles_file": _URL_BASE + "articles-training-" + self.config.name + "-20181122.zip?download=1",
112
+ "labels_file": _URL_BASE + "ground-truth-training-" + self.config.name + "-20181122.zip?download=1",
113
+ }
114
+
115
+ data_dir = {}
116
+ for key in urls:
117
+ data_dir[key] = dl_manager.download_and_extract(urls[key])
118
+
119
+ splits = []
120
+ for split in data_dir:
121
+ for key in data_dir[split]:
122
+ data_dir[split][key] = os.path.join(data_dir[split][key], os.listdir(data_dir[split][key])[0])
123
+ splits.append(datasets.SplitGenerator(name=split, gen_kwargs=data_dir[split]))
124
+ return splits
125
+
126
+ def _generate_examples(self, articles_file=None, labels_file=None):
127
+ """Yields examples."""
128
+ labels = {}
129
+ with open(labels_file, "rb") as f_labels:
130
+ tree = ET.parse(f_labels)
131
+ root = tree.getroot()
132
+ for label in root:
133
+ article_id = label.attrib["id"]
134
+ del label.attrib["labeled-by"]
135
+ labels[article_id] = label.attrib
136
+
137
+ with open(articles_file, "rb") as f_articles:
138
+ tree = ET.parse(f_articles)
139
+ root = tree.getroot()
140
+ for idx, article in enumerate(root):
141
+ example = {}
142
+ example["title"] = article.attrib["title"]
143
+ example["published_at"] = article.attrib.get("published-at", "")
144
+ example["id"] = article.attrib["id"]
145
+ example = {**example, **labels[example["id"]]}
146
+ example["hyperpartisan"] = example["hyperpartisan"] == "true"
147
+
148
+ example["text"] = ""
149
+ for child in article.getchildren():
150
+ example["text"] += ET.tostring(child).decode() + "\n"
151
+ example["text"] = example["text"].strip()
152
+ del example["id"]
153
+ yield idx, example