Datasets:
Tasks:
Text Classification
Modalities:
Text
Formats:
parquet
Sub-tasks:
sentiment-classification
Languages:
English
Size:
1K - 10K
ArXiv:
License:
Delete loading script
Browse files- poem_sentiment.py +0 -84
poem_sentiment.py
DELETED
|
@@ -1,84 +0,0 @@
|
|
| 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 |
-
"""Poem Sentiment: A sentiment dataset of poem verses"""
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
import datasets
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
_CITATION = """\
|
| 22 |
-
@misc{sheng2020investigating,
|
| 23 |
-
title={Investigating Societal Biases in a Poetry Composition System},
|
| 24 |
-
author={Emily Sheng and David Uthus},
|
| 25 |
-
year={2020},
|
| 26 |
-
eprint={2011.02686},
|
| 27 |
-
archivePrefix={arXiv},
|
| 28 |
-
primaryClass={cs.CL}
|
| 29 |
-
}
|
| 30 |
-
"""
|
| 31 |
-
|
| 32 |
-
_DESCRIPTION = """\
|
| 33 |
-
Poem Sentiment is a sentiment dataset of poem verses from Project Gutenberg. \
|
| 34 |
-
This dataset can be used for tasks such as sentiment classification or style transfer for poems.
|
| 35 |
-
"""
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
_HOMEPAGE = "https://github.com/google-research-datasets/poem-sentiment"
|
| 39 |
-
|
| 40 |
-
_BASE_URL = "https://raw.githubusercontent.com/google-research-datasets/poem-sentiment/master/data/"
|
| 41 |
-
_URLS = {
|
| 42 |
-
"train": f"{_BASE_URL}/train.tsv",
|
| 43 |
-
"dev": f"{_BASE_URL}/dev.tsv",
|
| 44 |
-
"test": f"{_BASE_URL}/test.tsv",
|
| 45 |
-
}
|
| 46 |
-
_LABEL_MAPPING = {-1: 0, 0: 2, 1: 1, 2: 3}
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
class PoemSentiment(datasets.GeneratorBasedBuilder):
|
| 50 |
-
"""Poem Sentiment: A sentiment dataset of poem verses"""
|
| 51 |
-
|
| 52 |
-
VERSION = datasets.Version("1.0.0")
|
| 53 |
-
|
| 54 |
-
def _info(self):
|
| 55 |
-
return datasets.DatasetInfo(
|
| 56 |
-
description=_DESCRIPTION,
|
| 57 |
-
features=datasets.Features(
|
| 58 |
-
{
|
| 59 |
-
"id": datasets.Value("int32"),
|
| 60 |
-
"verse_text": datasets.Value("string"),
|
| 61 |
-
"label": datasets.ClassLabel(names=["negative", "positive", "no_impact", "mixed"]),
|
| 62 |
-
}
|
| 63 |
-
),
|
| 64 |
-
supervised_keys=None,
|
| 65 |
-
homepage=_HOMEPAGE,
|
| 66 |
-
citation=_CITATION,
|
| 67 |
-
)
|
| 68 |
-
|
| 69 |
-
def _split_generators(self, dl_manager):
|
| 70 |
-
downloaded_files = dl_manager.download(_URLS)
|
| 71 |
-
return [
|
| 72 |
-
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
|
| 73 |
-
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
|
| 74 |
-
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]}),
|
| 75 |
-
]
|
| 76 |
-
|
| 77 |
-
def _generate_examples(self, filepath):
|
| 78 |
-
with open(filepath, encoding="utf-8") as f:
|
| 79 |
-
lines = f.readlines()
|
| 80 |
-
for line in lines:
|
| 81 |
-
fields = line.strip().split("\t")
|
| 82 |
-
idx, verse_text, label = fields
|
| 83 |
-
label = _LABEL_MAPPING[int(label)]
|
| 84 |
-
yield int(idx), {"id": int(idx), "verse_text": verse_text, "label": label}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|