Datasets:
cjvt
/

Modalities:
Tabular
Text
Languages:
Slovenian
Libraries:
Datasets
License:
File size: 4,081 Bytes
9db7fcc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a5b444f
9db7fcc
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
"""SentiNews: Manually sentiment annotated Slovenian news corpus."""


import csv

import datasets

_CITATION = """\
@article{buvcar2018annotated, 
        title={Annotated news corpora and a lexicon for sentiment analysis in Slovene}, 
        author={Bu{\v{c}}ar, Jo{\v{z}}e and {\v{Z}}nidar{\v{s}}i{\v{c}}, Martin and Povh, Janez}, 
        journal={Language Resources and Evaluation}, 
        volume={52}, 
        number={3}, 
        pages={895--919}, 
        year={2018}, 
        publisher={Springer}
}
"""

_DESCRIPTION = """\
SentiNews is a Slovenian sentiment classification dataset, consisting of news articles manually annotated with their 
sentiment by between 2 and 6 annotators. The news articles contain political, business, economic and financial content 
from the Slovenian news portals 24ur, Dnevnik, Finance, Rtvslo, and Žurnal24. The texts were annotated using the 
five-level Lickert scale (1 – very negative, 2 – negative, 3 – neutral, 4 – positive, and 5 – very positive) on three 
levels of granularity, i.e. on the document, paragraph, and sentence level. The final sentiment is determined using 
the following criterion: negative (if average of scores ≤ 2.4); neutral (if average of scores is between 2.4 and 3.6); 
positive (average of annotated scores ≥ 3.6).
"""

_HOMEPAGE = "https://github.com/19Joey85/Sentiment-annotated-news-corpus-and-sentiment-lexicon-in-Slovene/"

_LICENSE = "Creative Commons - Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)"

_URLS = {
    "document_level": "https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1110/SentiNews_document-level.txt",
    "paragraph_level": "https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1110/SentiNews_paragraph-level.txt",
    "sentence_level": "https://www.clarin.si/repository/xmlui/bitstream/handle/11356/1110/SentiNews_sentence-level.txt"
}


class Sentinews(datasets.GeneratorBasedBuilder):
    """SentiNews: Manually sentiment annotated Slovenian news corpus. Version 1.0."""

    VERSION = datasets.Version("1.0.0")

    BUILDER_CONFIGS = [
        datasets.BuilderConfig(name="document_level", version=VERSION, description="Dataset annotated at document level."),
        datasets.BuilderConfig(name="paragraph_level", version=VERSION, description="Dataset annotated at paragraph level."),
        datasets.BuilderConfig(name="sentence_level", version=VERSION, description="Dataset annotated at sentence level."),
    ]

    def _info(self):
        _config_features = {
            "nid": datasets.Value("uint16"),
            "content": datasets.Value("string"),
            "sentiment": datasets.Value("string")
        }

        if self.config.name == "paragraph_level":
            _config_features["pid"] = datasets.Value("uint8")
        elif self.config.name == "sentence_level":
            _config_features["pid"] = datasets.Value("uint8")
            _config_features["sid"] = datasets.Value("uint8")

        features = datasets.Features(_config_features)
        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            features=features,
            supervised_keys=("content", "sentiment"),
            homepage=_HOMEPAGE,
            license=_LICENSE,
            citation=_CITATION,
        )

    def _split_generators(self, dl_manager):
        urls = _URLS[self.config.name]
        data_file = dl_manager.download_and_extract(urls)
        return [datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"data_file": data_file})]

    def _generate_examples(self, data_file):
        _keys_to_return = ["nid", "content", "sentiment"]

        if self.config.name == "paragraph_level":
            _keys_to_return.append("pid")
        elif self.config.name == "sentence_level":
            _keys_to_return.append("pid")
            _keys_to_return.append("sid")

        with open(data_file, encoding="utf-8") as f:
            data = csv.DictReader(f, delimiter="\t")
            for idx, row in enumerate(data):
                yield idx, {_k: row[_k] for _k in _keys_to_return}