Datasets:
Tasks:
Text Generation
Formats:
parquet
Sub-tasks:
language-modeling
Languages:
Danish
Size:
1M - 10M
License:
KennethEnevoldsen
commited on
Added nordjylland news
Browse files- data/nordjyllandnews/create.py +20 -9
- data/nordjyllandnews/nordjyllandnews.parquet +2 -2
- uv.lock +1 -1
data/nordjyllandnews/create.py
CHANGED
@@ -4,11 +4,9 @@ This scripts download nordjylland news and converts it to the format of danish d
|
|
4 |
|
5 |
import random
|
6 |
from pathlib import Path
|
|
|
7 |
|
8 |
-
from datasets import load_dataset
|
9 |
-
|
10 |
-
source = "nordjyllandnews"
|
11 |
-
ds = load_dataset("alexandrainst/nordjylland-news-summarization", split="train")
|
12 |
|
13 |
schemas = [
|
14 |
"{summary}\n\n{text}",
|
@@ -16,13 +14,13 @@ schemas = [
|
|
16 |
"{text}\n\nReferat:\n{summary}",
|
17 |
"Lav et referat af nedenstående tekst:\n\nTekst:\n{text}\n\nReferat:\n{summary}",
|
18 |
]
|
|
|
19 |
|
20 |
|
21 |
def convert_sample(example):
|
22 |
schema = random.sample(schemas, k=1)[0]
|
23 |
-
|
24 |
new_example = dict(
|
25 |
-
|
26 |
source=source,
|
27 |
domain="News",
|
28 |
license="Creative Commons Legal Code\n\nCC0 1.0 Universal",
|
@@ -34,7 +32,20 @@ def convert_sample(example):
|
|
34 |
return new_example
|
35 |
|
36 |
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
-
|
40 |
-
|
|
|
4 |
|
5 |
import random
|
6 |
from pathlib import Path
|
7 |
+
from typing import cast
|
8 |
|
9 |
+
from datasets import Dataset, load_dataset
|
|
|
|
|
|
|
10 |
|
11 |
schemas = [
|
12 |
"{summary}\n\n{text}",
|
|
|
14 |
"{text}\n\nReferat:\n{summary}",
|
15 |
"Lav et referat af nedenstående tekst:\n\nTekst:\n{text}\n\nReferat:\n{summary}",
|
16 |
]
|
17 |
+
source = "nordjyllandnews"
|
18 |
|
19 |
|
20 |
def convert_sample(example):
|
21 |
schema = random.sample(schemas, k=1)[0]
|
|
|
22 |
new_example = dict(
|
23 |
+
text_new=schema.format(text=example["text"], summary=example["summary"]),
|
24 |
source=source,
|
25 |
domain="News",
|
26 |
license="Creative Commons Legal Code\n\nCC0 1.0 Universal",
|
|
|
32 |
return new_example
|
33 |
|
34 |
|
35 |
+
def main():
|
36 |
+
ds = load_dataset("alexandrainst/nordjylland-news-summarization", split="train")
|
37 |
+
ds = cast(Dataset, ds)
|
38 |
+
|
39 |
+
ds = ds.map(convert_sample, remove_columns=ds.column_names)
|
40 |
+
ds = ds.rename_columns({"text_new": "text"})
|
41 |
+
ds = ds.add_column("id", [f"{source}_{i}" for i in range(len(ds))]) # type: ignore
|
42 |
+
ds = ds.select_columns(
|
43 |
+
["text", "source", "id", "domain", "license", "added", "created", "metadata"]
|
44 |
+
)
|
45 |
+
|
46 |
+
save_path = Path(__file__).parent / f"{source}.parquet"
|
47 |
+
ds.to_parquet(save_path)
|
48 |
+
|
49 |
|
50 |
+
if __name__ == "__main__":
|
51 |
+
main()
|
data/nordjyllandnews/nordjyllandnews.parquet
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c577afba60df86561471214e53122783bff296b440e743926948c4fe01cd7b97
|
3 |
+
size 71246640
|
uv.lock
CHANGED
@@ -199,7 +199,7 @@ wheels = [
|
|
199 |
|
200 |
[[package]]
|
201 |
name = "danish-dynaword"
|
202 |
-
version = "1.0.
|
203 |
source = { virtual = "." }
|
204 |
dependencies = [
|
205 |
{ name = "datasets" },
|
|
|
199 |
|
200 |
[[package]]
|
201 |
name = "danish-dynaword"
|
202 |
+
version = "1.0.3"
|
203 |
source = { virtual = "." }
|
204 |
dependencies = [
|
205 |
{ name = "datasets" },
|