Datasets:
Tasks:
Text Classification
Modalities:
Text
Formats:
parquet
Sub-tasks:
sentiment-classification
Languages:
Swedish
Size:
100K - 1M
License:
Commit
•
e11dd7e
1
Parent(s):
1e129d3
Delete loading script
Browse files- swedish_reviews.py +0 -82
swedish_reviews.py
DELETED
@@ -1,82 +0,0 @@
|
|
1 |
-
# coding=utf-8
|
2 |
-
# Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
|
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 |
-
# Lint as: python3
|
17 |
-
|
18 |
-
|
19 |
-
import csv
|
20 |
-
import os
|
21 |
-
|
22 |
-
import datasets
|
23 |
-
from datasets.tasks import TextClassification
|
24 |
-
|
25 |
-
|
26 |
-
_DOWNLOAD_URL = "https://raw.githubusercontent.com/timpal0l/swedish-sentiment/main/swedish_sentiment.zip"
|
27 |
-
_TRAIN_FILE = "train.csv"
|
28 |
-
_VAL_FILE = "dev.csv"
|
29 |
-
_TEST_FILE = "test.csv"
|
30 |
-
|
31 |
-
_CITATION = ""
|
32 |
-
|
33 |
-
_DESCRIPTION = "Swedish reviews scarped from various public available websites"
|
34 |
-
|
35 |
-
|
36 |
-
class SwedishReviews(datasets.GeneratorBasedBuilder):
|
37 |
-
BUILDER_CONFIGS = [
|
38 |
-
datasets.BuilderConfig(
|
39 |
-
name="plain_text",
|
40 |
-
version=datasets.Version("1.0.0", ""),
|
41 |
-
description="Plain text import of the Swedish Reviews dataset",
|
42 |
-
)
|
43 |
-
]
|
44 |
-
|
45 |
-
def _info(self):
|
46 |
-
return datasets.DatasetInfo(
|
47 |
-
description=_DESCRIPTION,
|
48 |
-
features=datasets.Features(
|
49 |
-
{"text": datasets.Value("string"), "label": datasets.ClassLabel(names=["negative", "positive"])}
|
50 |
-
),
|
51 |
-
supervised_keys=None,
|
52 |
-
homepage="https://github.com/timpal0l/swedish-sentiment",
|
53 |
-
citation=_CITATION,
|
54 |
-
task_templates=[TextClassification(text_column="text", label_column="label")],
|
55 |
-
)
|
56 |
-
|
57 |
-
def _split_generators(self, dl_manager):
|
58 |
-
dl_dir = dl_manager.download_and_extract(_DOWNLOAD_URL)
|
59 |
-
return [
|
60 |
-
datasets.SplitGenerator(
|
61 |
-
name=datasets.Split.TEST,
|
62 |
-
gen_kwargs={"filepath": os.path.join(dl_dir, _TEST_FILE)},
|
63 |
-
),
|
64 |
-
datasets.SplitGenerator(
|
65 |
-
name=datasets.Split.VALIDATION,
|
66 |
-
gen_kwargs={"filepath": os.path.join(dl_dir, _VAL_FILE)},
|
67 |
-
),
|
68 |
-
datasets.SplitGenerator(
|
69 |
-
name=datasets.Split.TRAIN,
|
70 |
-
gen_kwargs={"filepath": os.path.join(dl_dir, _TRAIN_FILE)},
|
71 |
-
),
|
72 |
-
]
|
73 |
-
|
74 |
-
def _generate_examples(self, filepath):
|
75 |
-
"""This function returns the examples in the raw (text) form."""
|
76 |
-
with open(filepath, encoding="utf-8") as f:
|
77 |
-
reader = csv.DictReader(f)
|
78 |
-
for idx, row in enumerate(reader):
|
79 |
-
yield idx, {
|
80 |
-
"text": row["text"],
|
81 |
-
"label": row["sentiment"],
|
82 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|