test
Browse files- datacheck.sh +32 -0
- norwegian_parliament.py +3 -5
datacheck.sh
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
# Check if a file path is provided
|
4 |
+
if [ "$#" -ne 1 ]; then
|
5 |
+
echo "Usage: $0 <path_to_tsv_file>"
|
6 |
+
exit 1
|
7 |
+
fi
|
8 |
+
|
9 |
+
# Assign the file path to a variable
|
10 |
+
file_path="$1"
|
11 |
+
|
12 |
+
# Check if the file exists
|
13 |
+
if [ ! -f "$file_path" ]; then
|
14 |
+
echo "Error: File does not exist."
|
15 |
+
exit 1
|
16 |
+
fi
|
17 |
+
|
18 |
+
# Read each line from the file and count the number of fields
|
19 |
+
while IFS= read -r line; do
|
20 |
+
# Count the number of tabs, add 1 for the number of columns
|
21 |
+
col_count=$(echo -n "$line" | grep -o $'\t' | wc -l)
|
22 |
+
let col_count+=1
|
23 |
+
|
24 |
+
# Check if the number of columns is 2
|
25 |
+
if [ "$col_count" -ne 2 ]; then
|
26 |
+
echo "Error: Incorrect number of columns. Expected 4, but got $col_count in line: $line"
|
27 |
+
exit 1
|
28 |
+
fi
|
29 |
+
done < "$file_path"
|
30 |
+
|
31 |
+
echo "All rows have the correct number of columns."
|
32 |
+
|
norwegian_parliament.py
CHANGED
@@ -19,7 +19,7 @@ of the two major parties: Fremskrittspartiet and Sosialistisk Venstreparti.
|
|
19 |
|
20 |
_HOMEPAGE = "https://github.com/NBAiLab/notram/"
|
21 |
|
22 |
-
_BASE_URL = "https://
|
23 |
_URLS = {
|
24 |
"train": f"{_BASE_URL}train.tsv",
|
25 |
"dev": f"{_BASE_URL}dev.tsv",
|
@@ -38,7 +38,6 @@ class NorwegianParliament(datasets.GeneratorBasedBuilder):
|
|
38 |
{
|
39 |
"text": datasets.Value("string"),
|
40 |
"label": datasets.ClassLabel(names=["Fremskrittspartiet", "Sosialistisk Venstreparti"]),
|
41 |
-
"date": datasets.Value("string"),
|
42 |
}
|
43 |
),
|
44 |
supervised_keys=None,
|
@@ -56,13 +55,12 @@ class NorwegianParliament(datasets.GeneratorBasedBuilder):
|
|
56 |
|
57 |
def _generate_examples(self, filepath):
|
58 |
with open(filepath, encoding="utf-8") as file:
|
59 |
-
reader = csv.reader(file, delimiter="\t")
|
60 |
next(reader) # Skip the header
|
61 |
for idx, row in enumerate(reader):
|
62 |
-
|
63 |
yield idx, {
|
64 |
"text": text,
|
65 |
"label": label,
|
66 |
-
"date": date,
|
67 |
}
|
68 |
|
|
|
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.tsv",
|
25 |
"dev": f"{_BASE_URL}dev.tsv",
|
|
|
38 |
{
|
39 |
"text": datasets.Value("string"),
|
40 |
"label": datasets.ClassLabel(names=["Fremskrittspartiet", "Sosialistisk Venstreparti"]),
|
|
|
41 |
}
|
42 |
),
|
43 |
supervised_keys=None,
|
|
|
55 |
|
56 |
def _generate_examples(self, filepath):
|
57 |
with open(filepath, encoding="utf-8") as file:
|
58 |
+
reader = csv.reader(file, delimiter="\t")
|
59 |
next(reader) # Skip the header
|
60 |
for idx, row in enumerate(reader):
|
61 |
+
label, text = row
|
62 |
yield idx, {
|
63 |
"text": text,
|
64 |
"label": label,
|
|
|
65 |
}
|
66 |
|