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

Update files from the datasets library (from 1.2.0)

Browse files

Release notes: https://github.com/huggingface/datasets/releases/tag/1.2.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
README.md ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - machine-generated
4
+ language_creators:
5
+ - crowdsourced
6
+ languages:
7
+ - en
8
+ - nl
9
+ licenses:
10
+ - cc-by-nc-4-0
11
+ multilinguality:
12
+ - multilingual
13
+ size_categories:
14
+ - 100K< n<1M
15
+ source_datasets:
16
+ - original
17
+ task_categories:
18
+ - text-classification
19
+ task_ids:
20
+ - sentiment-classification
21
+ - multi-label-classification
22
+ ---
23
+
24
+ # Dataset Card for Dutch Social Media Collection
25
+
26
+ ## Table of Contents
27
+ - [Dataset Description](#dataset-description)
28
+ - [Dataset Summary](#dataset-summary)
29
+ - [Supported Tasks](#supported-tasks-and-leaderboards)
30
+ - [Languages](#languages)
31
+ - [Dataset Structure](#dataset-structure)
32
+ - [Data Instances](#data-instances)
33
+ - [Data Fields](#data-instances)
34
+ - [Data Splits](#data-instances)
35
+ - [Dataset Creation](#dataset-creation)
36
+ - [Curation Rationale](#curation-rationale)
37
+ - [Source Data](#source-data)
38
+ - [Annotations](#annotations)
39
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
40
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
41
+ - [Social Impact of Dataset](#social-impact-of-dataset)
42
+ - [Discussion of Biases](#discussion-of-biases)
43
+ - [Other Known Limitations](#other-known-limitations)
44
+ - [Additional Information](#additional-information)
45
+ - [Dataset Curators](#dataset-curators)
46
+ - [Licensing Information](#licensing-information)
47
+ - [Citation Information](#citation-information)
48
+
49
+ ## Dataset Description
50
+
51
+ - **Homepage:[Dutch Social Media Collection](http://datasets.coronawhy.org/dataset.xhtml?persistentId=doi:10.5072/FK2/MTPTL7)**
52
+ - **Repository: **
53
+ - **Paper:*(in-progress)* https://doi.org/10.5072/FK2/MTPTL7**
54
+ - **Leaderboard:**
55
+ - **Point of Contact: [Aakash Gupta](mailto:aakashg80@gmail.com)**
56
+
57
+ ### Dataset Summary
58
+
59
+ The dataset contains 10 files with around 271,342 tweets. The tweets are filtered via the official Twitter API to contain tweets in Dutch language or by users who have specified their location information within Netherlands geographical boundaries. Using natural language processing we have classified the tweets for their HISCO codes. If the user has provided their location within Dutch boundaries, we have also classified them to their respective provinces The objective of this dataset is to make research data available publicly in a FAIR (Findable, Accessible, Interoperable, Reusable) way. Twitter's Terms of Service Licensed under Attribution-NonCommercial 4.0 International (CC BY-NC 4.0) (2020-10-27)
60
+
61
+ ### Supported Tasks and Leaderboards
62
+
63
+ `sentiment analysis`, `multi-label classification`, `entity-extraction`
64
+
65
+ ### Languages
66
+
67
+ The text is primarily in Dutch with some tweets in English and other languages. The BCP 47 code is `nl` and `en`
68
+
69
+ ## Dataset Structure
70
+
71
+ ### Data Instances
72
+
73
+ An example of the data field will be:
74
+
75
+ ```
76
+ {
77
+ "full_text": "@pflegearzt @Friedelkorn @LAguja44 Pardon, wollte eigentlich das zitieren: \nhttps://t.co/ejO7bIMyj8\nMeine mentions sind inzw komplett undurchschaubar weil da Leute ihren supporterclub zwecks Likes zusammengerufen haben.",
78
+ "text_translation": "@pflegearzt @Friedelkorn @ LAguja44 Pardon wollte zitieren eigentlich das:\nhttps://t.co/ejO7bIMyj8\nMeine mentions inzw sind komplett undurchschaubar weil da Leute ihren supporter club Zwecks Likes zusammengerufen haben.",
79
+ "created_at": 1583756789000,
80
+ "screen_name": "TheoRettich",
81
+ "description": "I ❤️science, therefore a Commie. ☭ FALGSC: Part of a conspiracy which wants to achieve world domination. Tankie-Cornucopian. Ecology is a myth",
82
+ "desc_translation": "I ❤️science, Therefore a Commie. ☭ FALGSC: Part of a conspiracy How many followers wants to Achieve World Domination. Tankie-Cornucopian. Ecology is a myth",
83
+ "weekofyear": 11,
84
+ "weekday": 0,
85
+ "day": 9,
86
+ "month": 3,
87
+ "year": 2020,
88
+ "location": "Netherlands",
89
+ "point_info": "Nederland",
90
+ "point": "(52.5001698, 5.7480821, 0.0)",
91
+ "latitude": 52.5001698,
92
+ "longitude": 5.7480821,
93
+ "altitude": 0,
94
+ "province": "Flevoland",
95
+ "hisco_standard": null,
96
+ "hisco_code": null,
97
+ "industry": false,
98
+ "sentiment_pattern": 0,
99
+ "subjective_pattern": 0
100
+ }
101
+ ```
102
+
103
+ ### Data Fields
104
+
105
+
106
+ | Column Name | Description |
107
+ | --- | --- |
108
+ | full_text | Original text in the tweet |
109
+ | text_translation | English translation of the full text |
110
+ | created_at | Date of tweet creation |
111
+ | screen_name | username of the tweet author |
112
+ | description | description as provided in the users bio |
113
+ | desc_translation | English translation of user's bio/ description |
114
+ | location | Location information as provided in the user's bio |
115
+ | weekofyear | week of the year |
116
+ | weekday | Day of the week information; Monday=0....Sunday = 6|
117
+ | month | Month of tweet creation |
118
+ | year | year of tweet creation |
119
+ | day | day of tweet creation |
120
+ | point_info | point information from location columnd |
121
+ | point | tuple giving lat, lon & altitude information |
122
+ | latitude | geo-referencing information derived from location data |
123
+ | longitude | geo-referencing information derived from location data |
124
+ | altitude | geo-referencing information derived from location data|
125
+ | province | Province given location data of user |
126
+ | hisco_standard | HISCO standard key word; if available in tweet |
127
+ | hisco_code| HISCO standard code as derived from `hisco_standard`|
128
+ | industry | Whether the tweet talks about industry `(True/False)` |
129
+ | sentiment_score | Sentiment score -1.0 to 1.0 |
130
+ | subjectivity_score | Subjectivity scores 0 to 1 |
131
+
132
+ Missing values are replaced with empty strings or -1 (-100 for missing sentiment_score).
133
+
134
+
135
+ ### Data Splits
136
+
137
+ Data has been split into Train: 60%, Validation: 20% and Test: 20%
138
+
139
+ ## Dataset Creation
140
+
141
+ ### Curation Rationale
142
+
143
+ [More Information Needed]
144
+
145
+ ### Source Data
146
+
147
+ #### Initial Data Collection and Normalization
148
+
149
+ The tweets were hydrated using Twitter's API and then filtered for those which were in Dutch language and/or for users who had mentioned that they were from within Netherlands geographical borders.
150
+
151
+ #### Who are the source language producers?
152
+
153
+ The language producers are twitter users who have identified their location within the geographical boundaries of Netherland. Or those who have tweeted in the dutch language!
154
+
155
+ ### Annotations
156
+
157
+ Using Natural language processing, we have classified the tweets on industry and for HSN HISCO codes.
158
+ Depending on the user's location, their provincial information is also added. Please check the file/column for detailed information.
159
+
160
+ The tweets are also classified on the sentiment & subjectivity scores.
161
+ Sentiment scores are between -1 to +1
162
+ Subjectivity scores are between 0 to 1
163
+
164
+ #### Annotation process
165
+
166
+ [More Information Needed]
167
+
168
+ #### Who are the annotators?
169
+
170
+ [More Information Needed]
171
+
172
+ ### Personal and Sensitive Information
173
+
174
+ As of writing this data card no anonymization has been carried out on the tweets or user data. As such, if the twitter user has shared any personal & sensitive information, then it may be available in this dataset.
175
+
176
+ ## Considerations for Using the Data
177
+
178
+ ### Social Impact of Dataset
179
+
180
+ [More Information Needed]
181
+
182
+ ### Discussion of Biases
183
+
184
+ [More Information Needed]
185
+
186
+ ### Other Known Limitations
187
+
188
+ [More Information Needed]
189
+
190
+ ## Additional Information
191
+
192
+ ### Dataset Curators
193
+
194
+ [Aakash Gupta](mailto:aakashg80@gmail.com)
195
+ *Th!nkEvolve Consulting* and Researcher at CoronaWhy
196
+
197
+ ### Licensing Information
198
+
199
+ CC BY-NC 4.0
200
+
201
+ ### Citation Information
202
+
203
+ @data{FK2/MTPTL7_2020,
204
+ author = {Gupta, Aakash},
205
+ publisher = {COVID-19 Data Hub},
206
+ title = {{Dutch social media collection}},
207
+ year = {2020},
208
+ version = {DRAFT VERSION},
209
+ doi = {10.5072/FK2/MTPTL7},
210
+ url = {https://doi.org/10.5072/FK2/MTPTL7}
211
+ }
dataset_infos.json ADDED
@@ -0,0 +1 @@
 
1
+ {"dutch_social": {"description": "The dataset contains around 271,342 tweets. The tweets are filtered via the official Twitter API to\ncontain tweets in Dutch language or by users who have specified their location information within Netherlands\ngeographical boundaries. Using natural language processing we have classified the tweets for their HISCO codes.\nIf the user has provided their location within Dutch boundaries, we have also classified them to their respective\nprovinces The objective of this dataset is to make research data available publicly in a FAIR (Findable, Accessible,\nInteroperable, Reusable) way. Twitter's Terms of Service Licensed under Attribution-NonCommercial 4.0 International\n(CC BY-NC 4.0) (2020-10-27)\n", "citation": "@data{FK2/MTPTL7_2020,\nauthor = {Gupta, Aakash},\npublisher = {COVID-19 Data Hub},\ntitle = {{Dutch social media collection}},\nyear = {2020},\nversion = {DRAFT VERSION},\ndoi = {10.5072/FK2/MTPTL7},\nurl = {https://doi.org/10.5072/FK2/MTPTL7}\n}\n", "homepage": "http://datasets.coronawhy.org/dataset.xhtml?persistentId=doi:10.5072/FK2/MTPTL7", "license": "CC BY-NC 4.0", "features": {"full_text": {"dtype": "string", "id": null, "_type": "Value"}, "text_translation": {"dtype": "string", "id": null, "_type": "Value"}, "screen_name": {"dtype": "string", "id": null, "_type": "Value"}, "description": {"dtype": "string", "id": null, "_type": "Value"}, "desc_translation": {"dtype": "string", "id": null, "_type": "Value"}, "location": {"dtype": "string", "id": null, "_type": "Value"}, "weekofyear": {"dtype": "int64", "id": null, "_type": "Value"}, "weekday": {"dtype": "int64", "id": null, "_type": "Value"}, "month": {"dtype": "int64", "id": null, "_type": "Value"}, "year": {"dtype": "int64", "id": null, "_type": "Value"}, "day": {"dtype": "int64", "id": null, "_type": "Value"}, "point_info": {"dtype": "string", "id": null, "_type": "Value"}, "point": {"dtype": "string", "id": null, "_type": "Value"}, "latitude": {"dtype": "float64", "id": null, "_type": "Value"}, "longitude": {"dtype": "float64", "id": null, "_type": "Value"}, "altitude": {"dtype": "float64", "id": null, "_type": "Value"}, "province": {"dtype": "string", "id": null, "_type": "Value"}, "hisco_standard": {"dtype": "string", "id": null, "_type": "Value"}, "hisco_code": {"dtype": "string", "id": null, "_type": "Value"}, "industry": {"dtype": "bool_", "id": null, "_type": "Value"}, "sentiment_pattern": {"dtype": "float64", "id": null, "_type": "Value"}, "subjective_pattern": {"dtype": "float64", "id": null, "_type": "Value"}, "label": {"num_classes": 3, "names": ["neg", "neu", "pos"], "names_file": null, "id": null, "_type": "ClassLabel"}}, "post_processed": null, "supervised_keys": null, "builder_name": "dutch_social", "config_name": "dutch_social", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 105569586, "num_examples": 162805, "dataset_name": "dutch_social"}, "test": {"name": "test", "num_bytes": 35185351, "num_examples": 54268, "dataset_name": "dutch_social"}, "validation": {"name": "validation", "num_bytes": 34334756, "num_examples": 54269, "dataset_name": "dutch_social"}}, "download_checksums": {"https://storage.googleapis.com/corona-tweet/dutch-tweets.zip": {"num_bytes": 68740666, "checksum": "29a080692e806d5f05011b3157ae2c91a7964c32cc90c7f30532ab6dc980053a"}}, "download_size": 68740666, "post_processing_size": null, "dataset_size": 175089693, "size_in_bytes": 243830359}}
dummy/dutch_social/1.1.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:770b3209c87309cc010a56c7243515c83a45296c27f15d8b1ad5edb5cce739a8
3
+ size 4570
dutch_social.py ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """DUTCH SOCIAL: Annotated Covid19 tweets in Dutch language (sentiment, industry codes & province)."""
16
+
17
+ from __future__ import absolute_import, division, print_function
18
+
19
+ import json
20
+ import os
21
+
22
+ import datasets
23
+
24
+
25
+ # TODO: Add BibTeX citation
26
+ # Find for instance the citation on arxiv or on the dataset repo/website
27
+ _CITATION = """\
28
+ @data{FK2/MTPTL7_2020,
29
+ author = {Gupta, Aakash},
30
+ publisher = {COVID-19 Data Hub},
31
+ title = {{Dutch social media collection}},
32
+ year = {2020},
33
+ version = {DRAFT VERSION},
34
+ doi = {10.5072/FK2/MTPTL7},
35
+ url = {https://doi.org/10.5072/FK2/MTPTL7}
36
+ }
37
+ """
38
+
39
+ # TODO: Add description of the dataset here
40
+ # You can copy an official description
41
+ _DESCRIPTION = """\
42
+ The dataset contains around 271,342 tweets. The tweets are filtered via the official Twitter API to
43
+ contain tweets in Dutch language or by users who have specified their location information within Netherlands
44
+ geographical boundaries. Using natural language processing we have classified the tweets for their HISCO codes.
45
+ If the user has provided their location within Dutch boundaries, we have also classified them to their respective
46
+ provinces The objective of this dataset is to make research data available publicly in a FAIR (Findable, Accessible,
47
+ Interoperable, Reusable) way. Twitter's Terms of Service Licensed under Attribution-NonCommercial 4.0 International
48
+ (CC BY-NC 4.0) (2020-10-27)
49
+ """
50
+
51
+ # TODO: Add a link to an official homepage for the dataset here
52
+ _HOMEPAGE = "http://datasets.coronawhy.org/dataset.xhtml?persistentId=doi:10.5072/FK2/MTPTL7"
53
+
54
+ # TODO: Add the licence for the dataset here if you can find it
55
+ _LICENSE = "CC BY-NC 4.0"
56
+
57
+ # TODO: Add link to the official dataset URLs here
58
+ # The HuggingFace dataset library don't host the datasets but only point to the original files
59
+ # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
60
+ _URLs = {"dutch_social": "https://storage.googleapis.com/corona-tweet/dutch-tweets.zip"}
61
+
62
+ _LANG = ["nl", "en"]
63
+
64
+
65
+ # TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
66
+ class DutchSocial(datasets.GeneratorBasedBuilder):
67
+ """
68
+ Annotated Covid19 tweets in Dutch language. The tweets were filtered for users who had indicated
69
+ their location within Netherlands or if the tweets were in Dutch language. The purpose of curating
70
+ these tweets is to measure the economic impact of the Covid19 pandemic
71
+ """
72
+
73
+ VERSION = datasets.Version("1.1.0")
74
+
75
+ # This is an example of a dataset with multiple configurations.
76
+ # If you don't want/need to define several sub-sets in your dataset,
77
+ # just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
78
+
79
+ # If you need to make complex sub-parts in the datasets with configurable options
80
+ # You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
81
+ # BUILDER_CONFIG_CLASS = MyBuilderConfig
82
+
83
+ # You will be able to load one or the other configurations in the following list with
84
+ # data = datasets.load_dataset('my_dataset', 'first_domain')
85
+ # data = datasets.load_dataset('my_dataset', 'second_domain')
86
+ BUILDER_CONFIGS = [
87
+ datasets.BuilderConfig(
88
+ name="dutch_social",
89
+ version=VERSION,
90
+ description="This part of my dataset provides config for the entire dataset",
91
+ )
92
+ # datasets.BuilderConfig(name="second_domain", version=VERSION, description="This part of my dataset covers a second domain"),
93
+ ]
94
+
95
+ def _info(self):
96
+ # TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
97
+ features = datasets.Features(
98
+ {
99
+ "full_text": datasets.Value("string"),
100
+ "text_translation": datasets.Value("string"),
101
+ "screen_name": datasets.Value("string"),
102
+ "description": datasets.Value("string"),
103
+ "desc_translation": datasets.Value("string"),
104
+ "location": datasets.Value("string"),
105
+ "weekofyear": datasets.Value("int64"),
106
+ "weekday": datasets.Value("int64"),
107
+ "month": datasets.Value("int64"),
108
+ "year": datasets.Value("int64"),
109
+ "day": datasets.Value("int64"),
110
+ "point_info": datasets.Value("string"),
111
+ "point": datasets.Value("string"),
112
+ "latitude": datasets.Value("float64"),
113
+ "longitude": datasets.Value("float64"),
114
+ "altitude": datasets.Value("float64"),
115
+ "province": datasets.Value("string"),
116
+ "hisco_standard": datasets.Value("string"),
117
+ "hisco_code": datasets.Value("string"),
118
+ "industry": datasets.Value("bool_"),
119
+ "sentiment_pattern": datasets.Value("float64"),
120
+ "subjective_pattern": datasets.Value("float64"),
121
+ "label": datasets.ClassLabel(num_classes=3, names=["neg", "neu", "pos"], names_file=None, id=None),
122
+ }
123
+ )
124
+ return datasets.DatasetInfo(
125
+ # This is the description that will appear on the datasets page.
126
+ description=_DESCRIPTION,
127
+ # This defines the different columns of the dataset and their types
128
+ features=features, # Here we define them above because they are different between the two configurations
129
+ # If there's a common (input, target) tuple from the features,
130
+ # specify them here. They'll be used if as_supervised=True in
131
+ # builder.as_dataset.
132
+ supervised_keys=None,
133
+ # Homepage of the dataset for documentation
134
+ homepage=_HOMEPAGE,
135
+ # License for the dataset if available
136
+ license=_LICENSE,
137
+ # Citation for the dataset
138
+ citation=_CITATION,
139
+ )
140
+
141
+ def _split_generators(self, dl_manager):
142
+ """Returns SplitGenerators."""
143
+ # TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
144
+ # If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
145
+
146
+ # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLs
147
+ # It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
148
+ # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
149
+ my_urls = _URLs[self.config.name]
150
+ data_dir = dl_manager.download_and_extract(my_urls)
151
+
152
+ return [
153
+ datasets.SplitGenerator(
154
+ name=datasets.Split.TRAIN,
155
+ # These kwargs will be passed to _generate_examples
156
+ gen_kwargs={
157
+ "filepath": os.path.join(data_dir, "train.jsonl"),
158
+ "split": "train",
159
+ },
160
+ ),
161
+ datasets.SplitGenerator(
162
+ name=datasets.Split.TEST,
163
+ # These kwargs will be passed to _generate_examples
164
+ gen_kwargs={"filepath": os.path.join(data_dir, "test.jsonl"), "split": "test"},
165
+ ),
166
+ datasets.SplitGenerator(
167
+ name=datasets.Split.VALIDATION,
168
+ # These kwargs will be passed to _generate_examples
169
+ gen_kwargs={
170
+ "filepath": os.path.join(data_dir, "dev.jsonl"),
171
+ "split": "dev",
172
+ },
173
+ ),
174
+ ]
175
+
176
+ def _generate_examples(self, filepath, split, key=None):
177
+ """ Yields examples. """
178
+ # TODO: This method will receive as arguments the `gen_kwargs` defined in the previous `_split_generators` method.
179
+ # It is in charge of opening the given file and yielding (key, example) tuples from the dataset
180
+ # The key is not important, it's more here for legacy reason (legacy from tfds)
181
+
182
+ with open(filepath, encoding="utf-8") as f:
183
+ for id_, data in enumerate(f):
184
+ data = json.loads(data)
185
+ yield id_, {
186
+ "full_text": "" if not isinstance(data["full_text"], str) else data["full_text"],
187
+ "text_translation": ""
188
+ if not isinstance(data["text_translation"], str)
189
+ else data["text_translation"],
190
+ "screen_name": "" if not isinstance(data["screen_name"], str) else data["screen_name"],
191
+ "description": "" if not isinstance(data["description"], str) else data["description"],
192
+ "desc_translation": ""
193
+ if not isinstance(data["desc_translation"], str)
194
+ else data["desc_translation"],
195
+ "location": "" if not isinstance(data["location"], str) else data["location"],
196
+ "weekofyear": -1 if data["weekofyear"] is None else data["weekofyear"],
197
+ "weekday": -1 if data["weekday"] is None else data["weekday"],
198
+ "month": -1 if data["month"] is None else data["month"],
199
+ "year": -1 if data["year"] is None else data["year"],
200
+ "day": -1 if data["day"] is None else data["day"],
201
+ "point_info": "" if isinstance(data["point_info"], str) else data["point_info"],
202
+ "point": "" if not isinstance(data["point"], str) else data["point"],
203
+ "latitude": -1 if data["latitude"] is None else data["latitude"],
204
+ "longitude": -1 if data["longitude"] is None else data["longitude"],
205
+ "altitude": -1 if data["altitude"] is None else data["altitude"],
206
+ "province": "" if not isinstance(data["province"], str) else data["province"],
207
+ "hisco_standard": "" if not isinstance(data["hisco_standard"], str) else data["hisco_standard"],
208
+ "hisco_code": "" if not isinstance(data["hisco_code"], str) else data["hisco_code"],
209
+ "industry": False if not isinstance(data["industry"], bool) else data["industry"],
210
+ "sentiment_pattern": -100 if data["sentiment_pattern"] is None else data["sentiment_pattern"],
211
+ "subjective_pattern": -1 if data["subjective_pattern"] is None else data["subjective_pattern"],
212
+ "label": data["label"],
213
+ }