Datasets:
Create mihvg.py
Browse files
mihvg.py
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2020 The TensorFlow Datasets Authors and the 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 |
+
"""MIHVG TOTAWARPAD dataset."""
|
18 |
+
|
19 |
+
|
20 |
+
import os
|
21 |
+
|
22 |
+
import datasets
|
23 |
+
|
24 |
+
|
25 |
+
_CITATION = """\
|
26 |
+
@misc{
|
27 |
+
author={Laszlo, David},
|
28 |
+
title={totag-arpad},
|
29 |
+
year={2023},
|
30 |
+
howpublished={\\url{https://github.com/stedko/totagarpad}}
|
31 |
+
}"""
|
32 |
+
|
33 |
+
_DESCRIPTION = """\
|
34 |
+
Tota W. Arpad cikkei a hvg-rol \
|
35 |
+
"""
|
36 |
+
|
37 |
+
|
38 |
+
class TotaGArpad(datasets.GeneratorBasedBuilder):
|
39 |
+
"""Tota Gep Arpad dataset builder."""
|
40 |
+
|
41 |
+
VERSION = datasets.Version("1.0.0")
|
42 |
+
|
43 |
+
def _info(self):
|
44 |
+
return datasets.DatasetInfo(
|
45 |
+
description=_DESCRIPTION,
|
46 |
+
features=datasets.Features({"text": datasets.Value("string")}),
|
47 |
+
supervised_keys=None,
|
48 |
+
homepage="https://github.com/stedko/totagarpad/blob/main/totawarpad-articles.txt",
|
49 |
+
citation=_CITATION,
|
50 |
+
)
|
51 |
+
|
52 |
+
def _split_generators(self, dl_manager):
|
53 |
+
"""Returns SplitGenerators."""
|
54 |
+
download_path = dl_manager.download_and_extract(
|
55 |
+
"https://raw.githubusercontent.com/stedko/totagarpad/main/totawarpad-articles.txt"
|
56 |
+
)
|
57 |
+
if os.path.isdir(download_path):
|
58 |
+
# During testing the download manager mock gives us a directory
|
59 |
+
txt_path = os.path.join(download_path, "input.txt")
|
60 |
+
else:
|
61 |
+
txt_path = download_path
|
62 |
+
with open(txt_path, "r", encoding="utf-8") as f:
|
63 |
+
text = f.read()
|
64 |
+
|
65 |
+
# 90/5/5 split
|
66 |
+
i = int(len(text) * 0.9)
|
67 |
+
train_text, text = text[:i], text[i:]
|
68 |
+
i = int(len(text) * 0.5)
|
69 |
+
validation_text, text = text[:i], text[i:]
|
70 |
+
test_text = text
|
71 |
+
|
72 |
+
return [
|
73 |
+
datasets.SplitGenerator(
|
74 |
+
name=datasets.Split.TRAIN,
|
75 |
+
# These kwargs will be passed to _generate_examples
|
76 |
+
gen_kwargs={"split_key": "train", "split_text": train_text},
|
77 |
+
),
|
78 |
+
datasets.SplitGenerator(
|
79 |
+
name=datasets.Split.VALIDATION,
|
80 |
+
gen_kwargs={"split_key": "validation", "split_text": validation_text},
|
81 |
+
),
|
82 |
+
datasets.SplitGenerator(
|
83 |
+
name=datasets.Split.TEST,
|
84 |
+
gen_kwargs={"split_key": "test", "split_text": test_text},
|
85 |
+
),
|
86 |
+
]
|
87 |
+
|
88 |
+
def _generate_examples(self, split_key, split_text):
|
89 |
+
"""Yields examples."""
|
90 |
+
data_key = split_key # Should uniquely identify the thing yielded
|
91 |
+
feature_dict = {"text": split_text}
|
92 |
+
yield data_key, feature_dict
|