NLPnISRINZ commited on
Commit
4f231b6
·
verified ·
1 Parent(s): 123cfd4

Delete loading script

Browse files
Files changed (1) hide show
  1. financial_phrasebank.py +0 -149
financial_phrasebank.py DELETED
@@ -1,149 +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
-
16
- """Financial Phrase Bank v1.0: Polar sentiment dataset of sentences from
17
- financial news. The dataset consists of 4840 sentences from English language
18
- financial news categorised by sentiment. The dataset is divided by agreement
19
- rate of 5-8 annotators."""
20
-
21
-
22
- import os
23
-
24
- import datasets
25
-
26
-
27
- _CITATION = """\
28
- @article{Malo2014GoodDO,
29
- title={Good debt or bad debt: Detecting semantic orientations in economic texts},
30
- author={P. Malo and A. Sinha and P. Korhonen and J. Wallenius and P. Takala},
31
- journal={Journal of the Association for Information Science and Technology},
32
- year={2014},
33
- volume={65}
34
- }
35
- """
36
-
37
- _DESCRIPTION = """\
38
- The key arguments for the low utilization of statistical techniques in
39
- financial sentiment analysis have been the difficulty of implementation for
40
- practical applications and the lack of high quality training data for building
41
- such models. Especially in the case of finance and economic texts, annotated
42
- collections are a scarce resource and many are reserved for proprietary use
43
- only. To resolve the missing training data problem, we present a collection of
44
- ∼ 5000 sentences to establish human-annotated standards for benchmarking
45
- alternative modeling techniques.
46
-
47
- The objective of the phrase level annotation task was to classify each example
48
- sentence into a positive, negative or neutral category by considering only the
49
- information explicitly available in the given sentence. Since the study is
50
- focused only on financial and economic domains, the annotators were asked to
51
- consider the sentences from the view point of an investor only; i.e. whether
52
- the news may have positive, negative or neutral influence on the stock price.
53
- As a result, sentences which have a sentiment that is not relevant from an
54
- economic or financial perspective are considered neutral.
55
-
56
- This release of the financial phrase bank covers a collection of 4840
57
- sentences. The selected collection of phrases was annotated by 16 people with
58
- adequate background knowledge on financial markets. Three of the annotators
59
- were researchers and the remaining 13 annotators were master’s students at
60
- Aalto University School of Business with majors primarily in finance,
61
- accounting, and economics.
62
-
63
- Given the large number of overlapping annotations (5 to 8 annotations per
64
- sentence), there are several ways to define a majority vote based gold
65
- standard. To provide an objective comparison, we have formed 4 alternative
66
- reference datasets based on the strength of majority agreement: all annotators
67
- agree, >=75% of annotators agree, >=66% of annotators agree and >=50% of
68
- annotators agree.
69
- """
70
-
71
- _HOMEPAGE = "https://www.kaggle.com/ankurzing/sentiment-analysis-for-financial-news"
72
-
73
- _LICENSE = "Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License"
74
-
75
- _REPO = "https://huggingface.co/datasets/financial_phrasebank/resolve/main/data"
76
- _URL = f"{_REPO}/FinancialPhraseBank-v1.0.zip"
77
-
78
-
79
- _VERSION = datasets.Version("1.0.0")
80
-
81
-
82
- class FinancialPhraseBankConfig(datasets.BuilderConfig):
83
- """BuilderConfig for FinancialPhraseBank."""
84
-
85
- def __init__(
86
- self,
87
- split,
88
- **kwargs,
89
- ):
90
- """BuilderConfig for Discovery.
91
- Args:
92
- filename_bit: `string`, the changing part of the filename.
93
- """
94
-
95
- super(FinancialPhraseBankConfig, self).__init__(name=f"sentences_{split}agree", version=_VERSION, **kwargs)
96
-
97
- self.path = os.path.join("FinancialPhraseBank-v1.0", f"Sentences_{split.title()}Agree.txt")
98
-
99
-
100
- class FinancialPhrasebank(datasets.GeneratorBasedBuilder):
101
-
102
- BUILDER_CONFIGS = [
103
- FinancialPhraseBankConfig(
104
- split="all",
105
- description="Sentences where all annotators agreed",
106
- ),
107
- FinancialPhraseBankConfig(split="75", description="Sentences where at least 75% of annotators agreed"),
108
- FinancialPhraseBankConfig(split="66", description="Sentences where at least 66% of annotators agreed"),
109
- FinancialPhraseBankConfig(split="50", description="Sentences where at least 50% of annotators agreed"),
110
- ]
111
-
112
- def _info(self):
113
- return datasets.DatasetInfo(
114
- description=_DESCRIPTION,
115
- features=datasets.Features(
116
- {
117
- "sentence": datasets.Value("string"),
118
- "label": datasets.features.ClassLabel(
119
- names=[
120
- "negative",
121
- "neutral",
122
- "positive",
123
- ]
124
- ),
125
- }
126
- ),
127
- supervised_keys=None,
128
- homepage=_HOMEPAGE,
129
- license=_LICENSE,
130
- citation=_CITATION,
131
- )
132
-
133
- def _split_generators(self, dl_manager):
134
- """Returns SplitGenerators."""
135
- data_dir = dl_manager.download_and_extract(_URL)
136
- return [
137
- datasets.SplitGenerator(
138
- name=datasets.Split.TRAIN,
139
- # These kwargs will be passed to _generate_examples
140
- gen_kwargs={"filepath": os.path.join(data_dir, self.config.path)},
141
- ),
142
- ]
143
-
144
- def _generate_examples(self, filepath):
145
- """Yields examples."""
146
- with open(filepath, encoding="iso-8859-1") as f:
147
- for id_, line in enumerate(f):
148
- sentence, label = line.rsplit("@", 1)
149
- yield id_, {"sentence": sentence, "label": label}