Update tota_gep_arpad.py
Browse files- tota_gep_arpad.py +2 -11
tota_gep_arpad.py
CHANGED
@@ -16,12 +16,9 @@
|
|
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},
|
@@ -31,10 +28,9 @@ _CITATION = """\
|
|
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 |
|
@@ -50,19 +46,16 @@ class TotaGArpad(datasets.GeneratorBasedBuilder):
|
|
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)
|
@@ -72,7 +65,6 @@ class TotaGArpad(datasets.GeneratorBasedBuilder):
|
|
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(
|
@@ -86,7 +78,6 @@ class TotaGArpad(datasets.GeneratorBasedBuilder):
|
|
86 |
]
|
87 |
|
88 |
def _generate_examples(self, split_key, split_text):
|
89 |
-
|
90 |
-
data_key = split_key # Should uniquely identify the thing yielded
|
91 |
feature_dict = {"text": split_text}
|
92 |
yield data_key, feature_dict
|
|
|
16 |
# Lint as: python3
|
17 |
"""MIHVG TOTAWARPAD dataset."""
|
18 |
|
|
|
19 |
import os
|
|
|
20 |
import datasets
|
21 |
|
|
|
22 |
_CITATION = """\
|
23 |
@misc{
|
24 |
author={Laszlo, David},
|
|
|
28 |
}"""
|
29 |
|
30 |
_DESCRIPTION = """\
|
31 |
+
Train dataset Tota W. Arpad cikkei a hvg-rol \
|
32 |
"""
|
33 |
|
|
|
34 |
class TotaGArpad(datasets.GeneratorBasedBuilder):
|
35 |
"""Tota Gep Arpad dataset builder."""
|
36 |
|
|
|
46 |
)
|
47 |
|
48 |
def _split_generators(self, dl_manager):
|
|
|
49 |
download_path = dl_manager.download_and_extract(
|
50 |
"https://raw.githubusercontent.com/stedko/totagarpad/main/totawarpad-articles.txt"
|
51 |
)
|
52 |
if os.path.isdir(download_path):
|
|
|
53 |
txt_path = os.path.join(download_path, "input.txt")
|
54 |
else:
|
55 |
txt_path = download_path
|
56 |
with open(txt_path, "r", encoding="utf-8") as f:
|
57 |
text = f.read()
|
58 |
|
|
|
59 |
i = int(len(text) * 0.9)
|
60 |
train_text, text = text[:i], text[i:]
|
61 |
i = int(len(text) * 0.5)
|
|
|
65 |
return [
|
66 |
datasets.SplitGenerator(
|
67 |
name=datasets.Split.TRAIN,
|
|
|
68 |
gen_kwargs={"split_key": "train", "split_text": train_text},
|
69 |
),
|
70 |
datasets.SplitGenerator(
|
|
|
78 |
]
|
79 |
|
80 |
def _generate_examples(self, split_key, split_text):
|
81 |
+
data_key = split_key
|
|
|
82 |
feature_dict = {"text": split_text}
|
83 |
yield data_key, feature_dict
|