Datasets:
Tasks:
Summarization
Modalities:
Text
Sub-tasks:
news-articles-summarization
Languages:
Hebrew
Size:
100K - 1M
License:
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import csv | |
import os.path | |
import datasets | |
from urllib.parse import urlparse | |
_CITATION = """ | |
""" | |
_DESCRIPTION = """\ | |
""" | |
class HebrewNewsConfig(datasets.BuilderConfig): | |
"""BuilderConfig""" | |
def __init__(self, **kwargs): | |
"""BuilderConfig | |
Args: | |
**kwargs: keyword arguments forwarded to super. | |
""" | |
super(HebrewNewsConfig, self).__init__(**kwargs) | |
class HebrewNews(datasets.GeneratorBasedBuilder): | |
"""HebrewNews dataset.""" | |
BUILDER_CONFIGS = [ | |
HebrewNewsConfig( | |
name="hebrew_news", version=datasets.Version("1.0.0"), | |
description=f"hebrew news dataset" | |
) | |
] | |
def _info(self): | |
return datasets.DatasetInfo( | |
description=_DESCRIPTION, | |
features=datasets.Features( | |
{ | |
"id": datasets.Value("string"), | |
"articleBody": datasets.Value("string"), | |
"description": datasets.Value("string"), | |
"headline": datasets.Value("string"), | |
"title": datasets.Value("string"), | |
} | |
), | |
supervised_keys=None, | |
homepage="", | |
citation=_CITATION, | |
) | |
def _split_generators(self, dl_manager): | |
"""Returns SplitGenerators.""" | |
urls_to_download = "data/news.tar.gz" | |
downloaded_files = dl_manager.download_and_extract(urls_to_download) | |
return [ | |
datasets.SplitGenerator( | |
name=datasets.Split.TRAIN, | |
gen_kwargs={"filepath": downloaded_files}, | |
), | |
] | |
def _generate_examples(self, filepath): | |
with open(filepath, encoding="utf-8") as f: | |
fieldnames = ["articleBody", "description", "headline", "title"] | |
reader = csv.DictReader(f, delimiter=",", fieldnames=fieldnames) | |
for idx, row in enumerate(reader): | |
yield idx, { | |
"id": idx, | |
"articleBody": row["articleBody"], | |
"description": row["description"], | |
"headline": row["headline"], | |
"title": row["title"], | |
} | |