imvladikon commited on
Commit
0935a99
1 Parent(s): 1dba994
Files changed (2) hide show
  1. data/news.tar.gz +3 -0
  2. hebrew_news.py +76 -0
data/news.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ca04dec098e4f775891e5c3ad9c32571e4c2c5d335eb4f44b4a5e71a63bfc64c
3
+ size 213600962
hebrew_news.py ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ import csv
4
+ import os.path
5
+
6
+ import datasets
7
+ from urllib.parse import urlparse
8
+
9
+ _CITATION = """
10
+ """
11
+
12
+ _DESCRIPTION = """\
13
+ """
14
+
15
+
16
+ class HebrewNewsConfig(datasets.BuilderConfig):
17
+ """BuilderConfig"""
18
+
19
+ def __init__(self, **kwargs):
20
+ """BuilderConfig
21
+ Args:
22
+ **kwargs: keyword arguments forwarded to super.
23
+ """
24
+ super(HebrewNewsConfig, self).__init__(**kwargs)
25
+
26
+
27
+ class HebrewNews(datasets.GeneratorBasedBuilder):
28
+ """HebrewNews dataset."""
29
+
30
+ BUILDER_CONFIGS = [
31
+ HebrewNewsConfig(
32
+ name="hebrew_news", version=datasets.Version("1.0.0"),
33
+ description=f"hebrew news dataset"
34
+ )
35
+ ]
36
+
37
+ def _info(self):
38
+ return datasets.DatasetInfo(
39
+ description=_DESCRIPTION,
40
+ features=datasets.Features(
41
+ {
42
+ "id": datasets.Value("string"),
43
+ "articleBody": datasets.Value("string"),
44
+ "description": datasets.Value("string"),
45
+ "headline": datasets.Value("string"),
46
+ "title": datasets.Value("string"),
47
+ }
48
+ ),
49
+ supervised_keys=None,
50
+ homepage="",
51
+ citation=_CITATION,
52
+ )
53
+
54
+ def _split_generators(self, dl_manager):
55
+ """Returns SplitGenerators."""
56
+ urls_to_download = "data/news.tar.gz"
57
+ downloaded_files = dl_manager.download_and_extract(urls_to_download)
58
+ return [
59
+ datasets.SplitGenerator(
60
+ name=datasets.Split.TRAIN,
61
+ gen_kwargs={"filepath": downloaded_files},
62
+ ),
63
+ ]
64
+
65
+ def _generate_examples(self, filepath):
66
+ with open(filepath, encoding="utf-8") as f:
67
+ fieldnames = ["articleBody", "description", "headline", "title"]
68
+ reader = csv.DictReader(f, delimiter=",", fieldnames=fieldnames)
69
+ for idx, row in enumerate(reader):
70
+ yield idx, {
71
+ "id": idx,
72
+ "articleBody": row["articleBody"],
73
+ "description": row["description"],
74
+ "headline": row["headline"],
75
+ "title": row["title"],
76
+ }