Commit
•
5bac74b
1
Parent(s):
cc356cd
Delete loading script
Browse files- hebrew_this_world.py +0 -97
hebrew_this_world.py
DELETED
@@ -1,97 +0,0 @@
|
|
1 |
-
# coding=utf-8
|
2 |
-
# Copyright 2020 HuggingFace Datasets Authors.
|
3 |
-
#
|
4 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
# you may not use this file except in compliance with the License.
|
6 |
-
# You may obtain a copy of the License at
|
7 |
-
#
|
8 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
-
#
|
10 |
-
# Unless required by applicable law or agreed to in writing, software
|
11 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
-
# See the License for the specific language governing permissions and
|
14 |
-
# limitations under the License.
|
15 |
-
|
16 |
-
# Lint as: python3
|
17 |
-
"""HebrewThisWorld: A corpus from https://thisworld.online/."""
|
18 |
-
|
19 |
-
|
20 |
-
import csv
|
21 |
-
import ctypes
|
22 |
-
|
23 |
-
import datasets
|
24 |
-
|
25 |
-
|
26 |
-
_DESCRIPTION = """\
|
27 |
-
HebrewThisWorld is a data set consists of 2028 issues of the newspaper 'This World' edited by Uri Avnery and were published between 1950 and 1989. Released under the AGPLv3 license."""
|
28 |
-
|
29 |
-
csv.field_size_limit(int(ctypes.c_ulong(-1).value // 2))
|
30 |
-
|
31 |
-
_TRAIN_DOWNLOAD_URLS = [
|
32 |
-
"https://github.com/imvladikon/datasets_additional/raw/master/data/thisworld1/metadata_0.csv",
|
33 |
-
"https://github.com/imvladikon/datasets_additional/raw/master/data/thisworld1/metadata_1.csv",
|
34 |
-
"https://github.com/imvladikon/datasets_additional/raw/master/data/thisworld1/metadata_2.csv",
|
35 |
-
"https://github.com/imvladikon/datasets_additional/raw/master/data/thisworld1/metadata_3.csv",
|
36 |
-
"https://github.com/imvladikon/datasets_additional/raw/master/data/thisworld1/metadata_4.csv",
|
37 |
-
"https://github.com/imvladikon/datasets_additional/raw/master/data/thisworld1/metadata_5.csv",
|
38 |
-
"https://github.com/imvladikon/datasets_additional/raw/master/data/thisworld1/metadata_6.csv",
|
39 |
-
"https://github.com/imvladikon/datasets_additional/raw/master/data/thisworld1/metadata_7.csv",
|
40 |
-
"https://github.com/imvladikon/datasets_additional/raw/master/data/thisworld1/metadata_8.csv",
|
41 |
-
"https://github.com/imvladikon/datasets_additional/raw/master/data/thisworld1/metadata_9.csv",
|
42 |
-
]
|
43 |
-
|
44 |
-
|
45 |
-
class HebrewThisWorld(datasets.GeneratorBasedBuilder):
|
46 |
-
"""HebrewThisWorld: Corpus from the newspaper ThisWorld"""
|
47 |
-
|
48 |
-
VERSION = datasets.Version("0.1.0")
|
49 |
-
|
50 |
-
def _info(self):
|
51 |
-
return datasets.DatasetInfo(
|
52 |
-
description=_DESCRIPTION,
|
53 |
-
features=datasets.Features(
|
54 |
-
{
|
55 |
-
"issue_num": datasets.Value("int64"),
|
56 |
-
"page_count": datasets.Value("int64"),
|
57 |
-
"date": datasets.Value("string"),
|
58 |
-
"date_he": datasets.Value("string"),
|
59 |
-
"year": datasets.Value("string"),
|
60 |
-
"href": datasets.Value("string"),
|
61 |
-
"pdf": datasets.Value("string"),
|
62 |
-
"coverpage": datasets.Value("string"),
|
63 |
-
"backpage": datasets.Value("string"),
|
64 |
-
"content": datasets.Value("string"),
|
65 |
-
"url": datasets.Value("string"),
|
66 |
-
}
|
67 |
-
),
|
68 |
-
homepage="https://github.com/thisworld1/thisworld.online/",
|
69 |
-
)
|
70 |
-
|
71 |
-
def _split_generators(self, dl_manager):
|
72 |
-
train_path = dl_manager.download_and_extract(_TRAIN_DOWNLOAD_URLS)
|
73 |
-
|
74 |
-
return [
|
75 |
-
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_path}),
|
76 |
-
]
|
77 |
-
|
78 |
-
def _generate_examples(self, filepath):
|
79 |
-
"""Generate Hebrew ThisWorld examples."""
|
80 |
-
for file in filepath:
|
81 |
-
with open(file, encoding="utf-8") as csv_file:
|
82 |
-
csv_reader = csv.DictReader(csv_file)
|
83 |
-
for data in csv_reader:
|
84 |
-
id_ = data["issue_num"]
|
85 |
-
yield id_, {
|
86 |
-
"issue_num": data["issue_num"],
|
87 |
-
"page_count": data["page_count"],
|
88 |
-
"date": data["date"],
|
89 |
-
"date_he": data["date_he"],
|
90 |
-
"year": data["year"],
|
91 |
-
"href": data["href"],
|
92 |
-
"pdf": data["pdf"],
|
93 |
-
"coverpage": data["coverpage"],
|
94 |
-
"backpage": data["backpage"],
|
95 |
-
"content": data["content"],
|
96 |
-
"url": data["url"],
|
97 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|