jsonlines
Browse files- {data → csv}/dev.csv +0 -0
- {data → csv}/test.csv +0 -0
- {data → csv}/train.csv +0 -0
- data/dev.jsonl +0 -0
- data/test.jsonl +0 -0
- data/train.jsonl +0 -0
- dataset_infos.json +65 -1
- {data → tsv}/dev.tsv +0 -0
- {data → tsv}/test.tsv +0 -0
- {data → tsv}/train.tsv +0 -0
- utils/convert_csv_to_json.py +47 -0
- utils/convert_tsv_to_json.py +42 -0
- utils/dataset_infos.json +1 -0
- norwegian_parliament.py → utils/norwegian_parliament.py +0 -0
- norwegian_parliament_backup.py → utils/norwegian_parliament_backup.py +0 -0
{data → csv}/dev.csv
RENAMED
File without changes
|
{data → csv}/test.csv
RENAMED
File without changes
|
{data → csv}/train.csv
RENAMED
File without changes
|
data/dev.jsonl
ADDED
The diff for this file is too large to render.
See raw diff
|
|
data/test.jsonl
ADDED
The diff for this file is too large to render.
See raw diff
|
|
data/train.jsonl
ADDED
The diff for this file is too large to render.
See raw diff
|
|
dataset_infos.json
CHANGED
@@ -1 +1,65 @@
|
|
1 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"NbAiLab/norwegian_parliament": {
|
3 |
+
"description": "The Norwegian Parliament Speeches dataset contains transcriptions of speeches made by members of the Norwegian Parliament. The dataset covers speeches from two major parties: Fremskrittspartiet and Sosialistisk Venstreparti from 1998 to 2016.",
|
4 |
+
"citation": "@misc{nbailab_norwegian_parliament, title={Norwegian Parliament Speech Dataset}, author={NbAiLab}, year={2021}}",
|
5 |
+
"homepage": "https://github.com/NBAiLab/notram/",
|
6 |
+
"license": "",
|
7 |
+
"features": {
|
8 |
+
"label": {
|
9 |
+
"dtype": "string",
|
10 |
+
"_type": "Value"
|
11 |
+
},
|
12 |
+
"text": {
|
13 |
+
"dtype": "string",
|
14 |
+
"_type": "Value"
|
15 |
+
},
|
16 |
+
"full_label": {
|
17 |
+
"dtype": "string",
|
18 |
+
"_type": "Value"
|
19 |
+
},
|
20 |
+
"date": {
|
21 |
+
"dtype": "string",
|
22 |
+
"_type": "Value"
|
23 |
+
}
|
24 |
+
},
|
25 |
+
"splits": {
|
26 |
+
"train": {
|
27 |
+
"name": "train",
|
28 |
+
"num_bytes": 7513062,
|
29 |
+
"num_examples": 3600,
|
30 |
+
"dataset_name": "NbAiLab/norwegian_parliament"
|
31 |
+
},
|
32 |
+
"validation": {
|
33 |
+
"name": "validation",
|
34 |
+
"num_bytes": 2689316,
|
35 |
+
"num_examples": 1200,
|
36 |
+
"dataset_name": "NbAiLab/norwegian_parliament"
|
37 |
+
},
|
38 |
+
"test": {
|
39 |
+
"name": "test",
|
40 |
+
"num_bytes": 2651233,
|
41 |
+
"num_examples": 1200,
|
42 |
+
"dataset_name": "NbAiLab/norwegian_parliament"
|
43 |
+
}
|
44 |
+
},
|
45 |
+
"post_processed": null,
|
46 |
+
"supervised_keys": {
|
47 |
+
"input": "text",
|
48 |
+
"output": "label"
|
49 |
+
},
|
50 |
+
"builder_name": "norwegian_parliament",
|
51 |
+
"config_name": "default",
|
52 |
+
"version": {
|
53 |
+
"version_str": "1.0.0",
|
54 |
+
"description": "Initial version.",
|
55 |
+
"major": 1,
|
56 |
+
"minor": 0,
|
57 |
+
"patch": 0
|
58 |
+
},
|
59 |
+
"download_size": 12848611,
|
60 |
+
"post_processing_size": null,
|
61 |
+
"dataset_size": 12848611,
|
62 |
+
"size_in_bytes": 25697222
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
{data → tsv}/dev.tsv
RENAMED
File without changes
|
{data → tsv}/test.tsv
RENAMED
File without changes
|
{data → tsv}/train.tsv
RENAMED
File without changes
|
utils/convert_csv_to_json.py
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import csv
|
2 |
+
import json
|
3 |
+
import argparse
|
4 |
+
|
5 |
+
def convert_csv_to_jsonl(input_csv_path):
|
6 |
+
# Generate the output file name by replacing .csv with .jsonl
|
7 |
+
output_jsonl_path = input_csv_path.rsplit('.', 1)[0] + '.jsonl'
|
8 |
+
|
9 |
+
# Open the input CSV file and the output JSON lines file
|
10 |
+
with open(input_csv_path, mode='r', encoding='utf-8') as csv_file, \
|
11 |
+
open(output_jsonl_path, mode='w', encoding='utf-8') as jsonl_file:
|
12 |
+
|
13 |
+
# Create a CSV reader object to read the CSV file
|
14 |
+
csv_reader = csv.reader(csv_file, delimiter=',')
|
15 |
+
|
16 |
+
# Iterate over each row in the CSV file
|
17 |
+
for row in csv_reader:
|
18 |
+
# Each row should have exactly four columns: label, text, full_label, date
|
19 |
+
if len(row) == 4:
|
20 |
+
label, text, full_label, date = row
|
21 |
+
# Create a dictionary to represent this record
|
22 |
+
record = {
|
23 |
+
'label': label,
|
24 |
+
'text': text,
|
25 |
+
'full_label': full_label,
|
26 |
+
'date': date
|
27 |
+
}
|
28 |
+
# Convert the dictionary to a JSON string and write to the JSON lines file
|
29 |
+
jsonl_file.write(json.dumps(record) + '\n')
|
30 |
+
else:
|
31 |
+
print(f"Skipping malformed row: {row}")
|
32 |
+
|
33 |
+
def main():
|
34 |
+
# Create argument parser
|
35 |
+
parser = argparse.ArgumentParser(description="Convert CSV file to JSONL file.")
|
36 |
+
# Add argument for input CSV file
|
37 |
+
parser.add_argument("input_csv_path", type=str, help="Path to the input CSV file.")
|
38 |
+
|
39 |
+
# Parse arguments
|
40 |
+
args = parser.parse_args()
|
41 |
+
|
42 |
+
# Convert CSV to JSONL using the provided input path
|
43 |
+
convert_csv_to_jsonl(args.input_csv_path)
|
44 |
+
|
45 |
+
if __name__ == "__main__":
|
46 |
+
main()
|
47 |
+
|
utils/convert_tsv_to_json.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import csv
|
2 |
+
import json
|
3 |
+
import argparse
|
4 |
+
|
5 |
+
def convert_tsv_to_jsonl(input_tsv_path):
|
6 |
+
# Generate the output file name by replacing .tsv with .jsonl
|
7 |
+
output_jsonl_path = input_tsv_path.rsplit('.', 1)[0] + '.jsonl'
|
8 |
+
|
9 |
+
# Open the input TSV file and the output JSON lines file
|
10 |
+
with open(input_tsv_path, mode='r', encoding='utf-8') as tsv_file, \
|
11 |
+
open(output_jsonl_path, mode='w', encoding='utf-8') as jsonl_file:
|
12 |
+
|
13 |
+
# Create a CSV reader object to read the TSV file
|
14 |
+
tsv_reader = csv.reader(tsv_file, delimiter='\t')
|
15 |
+
|
16 |
+
# Iterate over each row in the TSV file
|
17 |
+
for row in tsv_reader:
|
18 |
+
# Each row should have exactly two columns: label and text
|
19 |
+
if len(row) == 2:
|
20 |
+
label, text = row
|
21 |
+
# Create a dictionary to represent this record
|
22 |
+
record = {'label': label, 'text': text}
|
23 |
+
# Convert the dictionary to a JSON string and write to the JSON lines file
|
24 |
+
jsonl_file.write(json.dumps(record) + '\n')
|
25 |
+
else:
|
26 |
+
print(f"Skipping malformed row: {row}")
|
27 |
+
|
28 |
+
def main():
|
29 |
+
# Create argument parser
|
30 |
+
parser = argparse.ArgumentParser(description="Convert TSV file to JSONL file.")
|
31 |
+
# Add argument for input TSV file
|
32 |
+
parser.add_argument("input_tsv_path", type=str, help="Path to the input TSV file.")
|
33 |
+
|
34 |
+
# Parse arguments
|
35 |
+
args = parser.parse_args()
|
36 |
+
|
37 |
+
# Convert TSV to JSONL using the provided input path
|
38 |
+
convert_tsv_to_jsonl(args.input_tsv_path)
|
39 |
+
|
40 |
+
if __name__ == "__main__":
|
41 |
+
main()
|
42 |
+
|
utils/dataset_infos.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"default": {"description": "The Norwegian Parliament Speeches is a collection of text passages from\n1998 to 2016 and pronounced at the Norwegian Parliament (Storting) by members\nof the two major parties: Fremskrittspartiet and Sosialistisk Venstreparti.\n", "citation": "\n@InProceedings{--,\n author = {---},\n title = {---},\n booktitle = {---},\n year = 2021,\n address = \"---\"\n}\n", "homepage": "https://github.com/NBAiLab/notram/", "license": "", "features": {"text": {"dtype": "string", "id": null, "_type": "Value"}, "label": {"num_classes": 2, "names": ["Fremskrittspartiet", "Sosialistisk Venstreparti"], "names_file": null, "id": null, "_type": "ClassLabel"}, "date": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "norwegian_parliament", "config_name": "default", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 6646256, "num_examples": 3600, "dataset_name": "norwegian_parliament"}, "validation": {"name": "validation", "num_bytes": 2384359, "num_examples": 1200, "dataset_name": "norwegian_parliament"}, "test": {"name": "test", "num_bytes": 2350756, "num_examples": 1200, "dataset_name": "norwegian_parliament"}}, "download_checksums": {"https://storage.googleapis.com/notram-public/finetune_datasets/parliament_speeches_1998_2016_frp_or_sv/train.csv": {"num_bytes": 6691149, "checksum": "5138fa8521424df0feca43d64a6a75fb1f4d9f2e759cc78027a1dc3bb8bde7ea"}, "https://storage.googleapis.com/notram-public/finetune_datasets/parliament_speeches_1998_2016_frp_or_sv/dev.csv": {"num_bytes": 2399289, "checksum": "b5397e989015c558bc5fb5cc706282b3306a41e09e950559ac0b3eaea8d72dd2"}, "https://storage.googleapis.com/notram-public/finetune_datasets/parliament_speeches_1998_2016_frp_or_sv/test.csv": {"num_bytes": 2365709, "checksum": "d1ebce8715e69884be78713e78d34635c2e6bb67db05c46e5833c2fb433f3825"}}, "download_size": 11456147, "post_processing_size": null, "dataset_size": 11381371, "size_in_bytes": 22837518}}
|
norwegian_parliament.py → utils/norwegian_parliament.py
RENAMED
File without changes
|
norwegian_parliament_backup.py → utils/norwegian_parliament_backup.py
RENAMED
File without changes
|