Datasets:
Tasks:
Text Generation
Formats:
parquet
Sub-tasks:
language-modeling
Languages:
Danish
Size:
1M - 10M
License:
File size: 1,473 Bytes
1e9caf0 3ab36be 1e9caf0 3ab36be 1e9caf0 3ab36be 1e9caf0 4c4c016 1e9caf0 3ab36be 1e9caf0 4c4c016 1e9caf0 3ab36be 4c4c016 3ab36be 1e9caf0 3ab36be |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
"""
This scripts download nordjylland news and converts it to the format of danish dynaword
"""
import random
from pathlib import Path
from typing import cast
from datasets import Dataset, load_dataset
schemas = [
"{summary}\n\n{text}",
"{text}\n\nOpsummering:\n{summary}",
"{text}\n\nReferat:\n{summary}",
"Lav et referat af nedenstående tekst:\n\nTekst:\n{text}\n\nReferat:\n{summary}",
]
source = "nordjyllandnews"
def convert_sample(example):
schema = random.choice(schemas)
new_example = dict(
text_new=schema.format(text=example["text"], summary=example["summary"]),
source=source,
domain="News",
license="Creative Commons Legal Code\n\nCC0 1.0 Universal",
added="2024-12-16",
created="2000-01-01, 2024-01-01", # best guess
metadata={"source-pretty": "Nordjylland News"},
)
return new_example
def main():
ds = load_dataset("alexandrainst/nordjylland-news-summarization", split="train")
ds = cast(Dataset, ds)
ds = ds.map(convert_sample, remove_columns=ds.column_names)
ds = ds.rename_columns({"text_new": "text"})
ds = ds.add_column("id", [f"{source}_{i}" for i in range(len(ds))]) # type: ignore
ds = ds.select_columns(
["text", "source", "id", "added", "created", "license", "domain", "metadata"]
)
save_path = Path(__file__).parent / f"{source}.parquet"
ds.to_parquet(save_path)
if __name__ == "__main__":
main()
|