new data loader
Browse files- norwegian_parliament.py +10 -27
norwegian_parliament.py
CHANGED
@@ -1,23 +1,6 @@
|
|
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 |
-
"""Norwegian Parliament Speeches (1998, 2016)"""
|
16 |
import csv
|
17 |
-
|
18 |
import datasets
|
19 |
|
20 |
-
|
21 |
_CITATION = """
|
22 |
@InProceedings{--,
|
23 |
author = {---},
|
@@ -34,17 +17,15 @@ The Norwegian Parliament Speeches is a collection of text passages from
|
|
34 |
of the two major parties: Fremskrittspartiet and Sosialistisk Venstreparti.
|
35 |
"""
|
36 |
|
37 |
-
|
38 |
_HOMEPAGE = "https://github.com/NBAiLab/notram/"
|
39 |
|
40 |
-
_BASE_URL = "https://
|
41 |
_URLS = {
|
42 |
-
"train": f"{_BASE_URL}
|
43 |
-
"dev": f"{_BASE_URL}
|
44 |
-
"test": f"{_BASE_URL}
|
45 |
}
|
46 |
|
47 |
-
|
48 |
class NorwegianParliament(datasets.GeneratorBasedBuilder):
|
49 |
"""Norwegian Parliament Speeches (1998, 2016)"""
|
50 |
|
@@ -76,10 +57,12 @@ class NorwegianParliament(datasets.GeneratorBasedBuilder):
|
|
76 |
def _generate_examples(self, filepath):
|
77 |
with open(filepath, encoding="utf-8") as csv_file:
|
78 |
csv_reader = csv.reader(csv_file, delimiter=",")
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
83 |
"label": label,
|
84 |
"date": date,
|
85 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import csv
|
|
|
2 |
import datasets
|
3 |
|
|
|
4 |
_CITATION = """
|
5 |
@InProceedings{--,
|
6 |
author = {---},
|
|
|
17 |
of the two major parties: Fremskrittspartiet and Sosialistisk Venstreparti.
|
18 |
"""
|
19 |
|
|
|
20 |
_HOMEPAGE = "https://github.com/NBAiLab/notram/"
|
21 |
|
22 |
+
_BASE_URL = "https://raw.githubusercontent.com/your-username/your-repo/main/data/"
|
23 |
_URLS = {
|
24 |
+
"train": f"{_BASE_URL}train.csv",
|
25 |
+
"dev": f"{_BASE_URL}dev.csv",
|
26 |
+
"test": f"{_BASE_URL}test.csv",
|
27 |
}
|
28 |
|
|
|
29 |
class NorwegianParliament(datasets.GeneratorBasedBuilder):
|
30 |
"""Norwegian Parliament Speeches (1998, 2016)"""
|
31 |
|
|
|
57 |
def _generate_examples(self, filepath):
|
58 |
with open(filepath, encoding="utf-8") as csv_file:
|
59 |
csv_reader = csv.reader(csv_file, delimiter=",")
|
60 |
+
next(csv_reader) # Skip the header
|
61 |
+
for idx, row in enumerate(csv_reader):
|
62 |
+
index, text, label, date = row
|
63 |
+
yield idx, {
|
64 |
+
"text": text.strip('"'), # Remove surrounding quotes if necessary
|
65 |
"label": label,
|
66 |
"date": date,
|
67 |
}
|
68 |
+
|