Datasets:
Tasks:
Text Classification
Sub-tasks:
sentiment-classification
Languages:
English
Size:
10K<n<100K
License:
fhamborg
commited on
Commit
·
804b7b8
1
Parent(s):
4cd9b82
Add NewsMTSC dataset download
Browse files- README.md +84 -0
- dataset_info.json +1 -0
- news_mtsc_dataset.py +145 -0
README.md
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
languages:
|
3 |
+
- en
|
4 |
+
licenses:
|
5 |
+
- mit
|
6 |
+
size_categories:
|
7 |
+
- 1K<n<10K
|
8 |
+
---
|
9 |
+
# NewsMTSC dataset
|
10 |
+
|
11 |
+
The files contained in this archive are part of the dataset "NewsMTSC" described in our paper "NewsMTSC: (Multi-)Target-dependent Sentiment Classification in News Articles" published at the EACL 2021.
|
12 |
+
|
13 |
+
## Dataset
|
14 |
+
|
15 |
+
### Files
|
16 |
+
The dataset consists of three splits. In practical terms, we suggest to use the files as follows (more detailed information can be found in the paper):
|
17 |
+
|
18 |
+
* `train.jsonl` - For **training**.
|
19 |
+
* `devtest_mt.jsonl` - To evaluate a model's classification performance only on sentences that contain **at least two target mentions**. Note that the mentions were extracted to refer to different persons but in a few cases might indeed refer to the same person since we extracted them automatically.
|
20 |
+
* `devtest_rw.jsonl` - To evaluate a model's classification performance on a "**real-world**" set of sentences, i.e., the set was created with the objective to resemble real-world distribution as to sentiment and other factors mentioned in the paper.
|
21 |
+
|
22 |
+
|
23 |
+
### Format
|
24 |
+
Each split is stored in a JSONL file. In JSONL, each line represents one JSON object. In our dataset, each JSON object consists of:
|
25 |
+
|
26 |
+
1. `sentence_normalized`: a single sentence
|
27 |
+
2. `primary_gid`: an identifier that is unique within NewsMTSC
|
28 |
+
3. `targets`: one or more targets
|
29 |
+
|
30 |
+
Each target in `targets` consists of:
|
31 |
+
|
32 |
+
1. `Input.gid`: an identifier that is unique within NewsMTSC
|
33 |
+
2. `from`: the character-based, 0-indexed position of the first character of the target's mention within `sentence_normalized`
|
34 |
+
3. `to`: the last character of the target's mention
|
35 |
+
4. `mention`: the text of the mention
|
36 |
+
5. `polarity`: the sentiment of the sentence concerning the target's mention (2.0 = negative, 4.0 = neutral, 6.0 = positive)
|
37 |
+
6. `further_mentions` (optional): one or more coreferential mentions of the target within the sentence. Note that these were extracted automatically and thus might be incorrecet or not be complete. Further, our annotators labeled the sentiment concerning the main mention, which - depending on the sentence - might not be identical to the sentiment of the coreferences.
|
38 |
+
|
39 |
+
```
|
40 |
+
{
|
41 |
+
"primary_gid":"allsides_1192_476_17_— Judge Neil M. Gorsuch_126_139",
|
42 |
+
"sentence_normalized":"But neither side harbored any doubts, based on the judge’s opinions, other writings and the president who nominated him, that Judge Gorsuch would be a reliable conservative committed to following the original understanding of those who drafted and ratified the Constitution.",
|
43 |
+
"targets":[
|
44 |
+
{
|
45 |
+
"Input.gid":"allsides_1192_476_17_— Judge Neil M. Gorsuch_126_139",
|
46 |
+
"from":126,
|
47 |
+
"to":139,
|
48 |
+
"mention":"Judge Gorsuch",
|
49 |
+
"polarity":6.0,
|
50 |
+
"further_mentions":[
|
51 |
+
{
|
52 |
+
"from":116,
|
53 |
+
"to":119,
|
54 |
+
"mention":"him"
|
55 |
+
}
|
56 |
+
]
|
57 |
+
}
|
58 |
+
]
|
59 |
+
}
|
60 |
+
```
|
61 |
+
|
62 |
+
## Contact
|
63 |
+
|
64 |
+
If you want to get in touch, feel free to contact Felix Hamborg. If you find an issue with the dataset or model or have a question concerning either, please open an issue in the repository.
|
65 |
+
|
66 |
+
* Web: [https://felix.hamborg.eu/](https://felix.hamborg.eu/)
|
67 |
+
* Mail: [[email protected]](mailto:[email protected])
|
68 |
+
* Repository: [https://github.com/fhamborg/NewsMTSC](https://github.com/fhamborg/NewsMTSC)
|
69 |
+
|
70 |
+
|
71 |
+
## How to cite
|
72 |
+
|
73 |
+
If you use the dataset or parts of it, please cite our paper:
|
74 |
+
|
75 |
+
```
|
76 |
+
@InProceedings{Hamborg2021b,
|
77 |
+
author = {Hamborg, Felix and Donnay, Karsten},
|
78 |
+
title = {NewsMTSC: (Multi-)Target-dependent Sentiment Classification in News Articles},
|
79 |
+
booktitle = {Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics (EACL 2021)},
|
80 |
+
year = {2021},
|
81 |
+
month = {Apr.},
|
82 |
+
location = {Virtual Event},
|
83 |
+
}
|
84 |
+
```
|
dataset_info.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"description": "NewsMTSC Dataset: A large, manually annotated dataset for target-dependent sentiment classification in political news articles.\n", "citation": "@InProceedings{Hamborg2021b,\n author = {Hamborg, Felix and Donnay, Karsten},\n title = {NewsMTSC: (Multi-)Target-dependent Sentiment Classification in News Articles},\n booktitle = {Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics (EACL 2021)},\n year = {2021},\n month = {Apr.},\n location = {Virtual Event},\n}\n", "homepage": "https://github.com/fhamborg/NewsMTSC/", "license": "MIT", "features": {"primary_gid": {"dtype": "string", "id": null, "_type": "Value"}, "sentence_normalized": {"dtype": "string", "id": null, "_type": "Value"}, "targets": {"feature": {"Input.gid": {"dtype": "string", "id": null, "_type": "Value"}, "from": {"dtype": "uint32", "id": null, "_type": "Value"}, "to": {"dtype": "uint32", "id": null, "_type": "Value"}, "mention": {"dtype": "string", "id": null, "_type": "Value"}, "polarity": {"dtype": "float32", "id": null, "_type": "Value"}, "further_mentions": {"feature": {"from": {"dtype": "uint32", "id": null, "_type": "Value"}, "to": {"dtype": "uint32", "id": null, "_type": "Value"}, "mention": {"dtype": "string", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": null, "config_name": null, "version": null, "splits": null, "download_checksums": null, "download_size": null, "post_processing_size": null, "dataset_size": null, "size_in_bytes": null}
|
news_mtsc_dataset.py
ADDED
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
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 |
+
"""NewsMTSC Dataset: (Multi-)Target-dependent Sentiment Classification in News Articles Dataset"""
|
16 |
+
|
17 |
+
|
18 |
+
import csv
|
19 |
+
import json
|
20 |
+
import os
|
21 |
+
|
22 |
+
import datasets
|
23 |
+
|
24 |
+
_CITATION = """\
|
25 |
+
@InProceedings{Hamborg2021b,
|
26 |
+
author = {Hamborg, Felix and Donnay, Karsten},
|
27 |
+
title = {NewsMTSC: (Multi-)Target-dependent Sentiment Classification in News Articles},
|
28 |
+
booktitle = {Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics (EACL 2021)},
|
29 |
+
year = {2021},
|
30 |
+
month = {Apr.},
|
31 |
+
location = {Virtual Event},
|
32 |
+
}
|
33 |
+
"""
|
34 |
+
_DESCRIPTION = """\
|
35 |
+
NewsMTSC Dataset: A large, manually annotated dataset for target-dependent sentiment classification in political news articles.
|
36 |
+
"""
|
37 |
+
_HOMEPAGE = "https://github.com/fhamborg/NewsMTSC/"
|
38 |
+
_LICENSE = "MIT"
|
39 |
+
_URL = "https://raw.githubusercontent.com/fhamborg/NewsMTSC/a96f785fd3110c202e05e63579ddb30043eef128/NewsSentiment/experiments/default/datasets/"
|
40 |
+
_URLS = {
|
41 |
+
"mt": {
|
42 |
+
datasets.Split.TRAIN: _URL + "newsmtsc-mt/train.jsonl",
|
43 |
+
datasets.Split.VALIDATION: _URL + "newsmtsc-mt/dev.jsonl",
|
44 |
+
datasets.Split.TEST: _URL + "newsmtsc-mt/test.jsonl",
|
45 |
+
},
|
46 |
+
"rw": {
|
47 |
+
datasets.Split.TRAIN: _URL + "newsmtsc-rw/train.jsonl",
|
48 |
+
datasets.Split.VALIDATION: _URL + "newsmtsc-rw/dev.jsonl",
|
49 |
+
datasets.Split.TEST: _URL + "newsmtsc-rw/test.jsonl",
|
50 |
+
},
|
51 |
+
}
|
52 |
+
|
53 |
+
|
54 |
+
class AllowNoFurtherMentionsFeatures(datasets.Features):
|
55 |
+
def encode_example(self, example):
|
56 |
+
for target in example["targets"]:
|
57 |
+
if "further_mentions" not in target:
|
58 |
+
target["further_mentions"] = []
|
59 |
+
return super().encode_example(example)
|
60 |
+
|
61 |
+
|
62 |
+
class NewsMTSCDataset(datasets.GeneratorBasedBuilder):
|
63 |
+
"""NewsMTSC Dataset: A large, manually annotated dataset for target-dependent sentiment classification in political
|
64 |
+
news articles."""
|
65 |
+
|
66 |
+
VERSION = datasets.Version("1.0.0")
|
67 |
+
|
68 |
+
BUILDER_CONFIGS = [
|
69 |
+
datasets.BuilderConfig(name="mt", version=VERSION, description="Multi-target: sentences that contain at least two target mentions."),
|
70 |
+
datasets.BuilderConfig(name="rw", version=VERSION, description="Real-world: aims that sentences resemble real-world distribution as to sentiment and other factors mentioned in the paper"),
|
71 |
+
]
|
72 |
+
|
73 |
+
DEFAULT_CONFIG_NAME = "rw"
|
74 |
+
|
75 |
+
def _info(self):
|
76 |
+
return datasets.DatasetInfo(
|
77 |
+
# This is the description that will appear on the datasets page.
|
78 |
+
description=_DESCRIPTION,
|
79 |
+
# This defines the different columns of the dataset and their types
|
80 |
+
features=AllowNoFurtherMentionsFeatures(
|
81 |
+
{
|
82 |
+
"primary_gid": datasets.Value("string"),
|
83 |
+
"sentence_normalized": datasets.Value("string"),
|
84 |
+
"targets": datasets.features.Sequence(
|
85 |
+
{
|
86 |
+
"Input.gid": datasets.Value("string"),
|
87 |
+
"from": datasets.Value("uint32"),
|
88 |
+
"to": datasets.Value("uint32"),
|
89 |
+
"mention": datasets.Value("string"),
|
90 |
+
"polarity": datasets.Value("float"),
|
91 |
+
"further_mentions": datasets.features.Sequence(
|
92 |
+
{
|
93 |
+
"from": datasets.Value("uint32"),
|
94 |
+
"to": datasets.Value("uint32"),
|
95 |
+
"mention": datasets.Value("string"),
|
96 |
+
},
|
97 |
+
),
|
98 |
+
},
|
99 |
+
),
|
100 |
+
},
|
101 |
+
),
|
102 |
+
homepage=_HOMEPAGE,
|
103 |
+
license=_LICENSE,
|
104 |
+
citation=_CITATION,
|
105 |
+
)
|
106 |
+
|
107 |
+
def _split_generators(self, dl_manager):
|
108 |
+
urls = _URLS[self.config.name]
|
109 |
+
data_dir = dl_manager.download(urls)
|
110 |
+
return [
|
111 |
+
datasets.SplitGenerator(
|
112 |
+
name=datasets.Split.TRAIN,
|
113 |
+
# These kwargs will be passed to _generate_examples
|
114 |
+
gen_kwargs={
|
115 |
+
"filepath": data_dir[datasets.Split.TRAIN],
|
116 |
+
"split": "train",
|
117 |
+
},
|
118 |
+
),
|
119 |
+
datasets.SplitGenerator(
|
120 |
+
name=datasets.Split.TEST,
|
121 |
+
# These kwargs will be passed to _generate_examples
|
122 |
+
gen_kwargs={
|
123 |
+
"filepath": data_dir[datasets.Split.TEST],
|
124 |
+
"split": "test"
|
125 |
+
},
|
126 |
+
),
|
127 |
+
datasets.SplitGenerator(
|
128 |
+
name=datasets.Split.VALIDATION,
|
129 |
+
# These kwargs will be passed to _generate_examples
|
130 |
+
gen_kwargs={
|
131 |
+
"filepath": data_dir[datasets.Split.VALIDATION],
|
132 |
+
"split": "dev",
|
133 |
+
},
|
134 |
+
),
|
135 |
+
]
|
136 |
+
|
137 |
+
def _generate_examples(self, filepath, split):
|
138 |
+
with open(filepath, encoding="utf-8") as f:
|
139 |
+
for row in f:
|
140 |
+
data = json.loads(row)
|
141 |
+
if split == "test":
|
142 |
+
for target in data["targets"]:
|
143 |
+
target["polarity"] = None
|
144 |
+
yield data["primary_gid"], data
|
145 |
+
|