Update files from the datasets library (from 1.16.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.16.0
README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
---
|
|
|
|
| 2 |
annotations_creators:
|
| 3 |
- expert-generated
|
| 4 |
- no-annotation
|
|
|
|
| 1 |
---
|
| 2 |
+
pretty_name: Thai Literature Corpora (TLC)
|
| 3 |
annotations_creators:
|
| 4 |
- expert-generated
|
| 5 |
- no-annotation
|
tlc.py
CHANGED
|
@@ -4,7 +4,6 @@
|
|
| 4 |
|
| 5 |
|
| 6 |
import json
|
| 7 |
-
import os
|
| 8 |
|
| 9 |
import datasets
|
| 10 |
|
|
@@ -44,6 +43,11 @@ _URLs = {
|
|
| 44 |
"tlcv2.0": "https://github.com/jitkapat/thailitcorpus/releases/download/v.2.0/tlc_v.2.0.tar.gz",
|
| 45 |
"tnhcv1.0": "https://github.com/jitkapat/thailitcorpus/releases/download/v.1.0/tnhc_v.1.0.tar.gz",
|
| 46 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
|
| 49 |
class TlcConfig(datasets.BuilderConfig):
|
|
@@ -102,27 +106,24 @@ class Tlc(datasets.GeneratorBasedBuilder):
|
|
| 102 |
)
|
| 103 |
|
| 104 |
def _split_generators(self, dl_manager):
|
| 105 |
-
|
| 106 |
|
| 107 |
return [
|
| 108 |
datasets.SplitGenerator(
|
| 109 |
name=datasets.Split.TRAIN,
|
| 110 |
-
gen_kwargs={"
|
| 111 |
)
|
| 112 |
]
|
| 113 |
|
| 114 |
-
def _generate_examples(self,
|
| 115 |
-
if self.config.name.startswith("tlc"):
|
| 116 |
-
files = [os.path.join(directory, "นิราศอิเหนา.json")]
|
| 117 |
-
else:
|
| 118 |
-
files = [os.path.join(directory, "กาพย์เห่เรือ.json")]
|
| 119 |
-
|
| 120 |
_id = 0
|
| 121 |
-
for
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
|
| 6 |
import json
|
|
|
|
| 7 |
|
| 8 |
import datasets
|
| 9 |
|
|
|
|
| 43 |
"tlcv2.0": "https://github.com/jitkapat/thailitcorpus/releases/download/v.2.0/tlc_v.2.0.tar.gz",
|
| 44 |
"tnhcv1.0": "https://github.com/jitkapat/thailitcorpus/releases/download/v.1.0/tnhc_v.1.0.tar.gz",
|
| 45 |
}
|
| 46 |
+
_FILENAMES = {
|
| 47 |
+
"tlcv1.0": "นิราศอิเหนา.json",
|
| 48 |
+
"tlcv2.0": "นิราศอิเหนา.json",
|
| 49 |
+
"tnhcv1.0": "กาพย์เห่เรือ.json",
|
| 50 |
+
}
|
| 51 |
|
| 52 |
|
| 53 |
class TlcConfig(datasets.BuilderConfig):
|
|
|
|
| 106 |
)
|
| 107 |
|
| 108 |
def _split_generators(self, dl_manager):
|
| 109 |
+
archive = dl_manager.download(_URLs[self.config.name])
|
| 110 |
|
| 111 |
return [
|
| 112 |
datasets.SplitGenerator(
|
| 113 |
name=datasets.Split.TRAIN,
|
| 114 |
+
gen_kwargs={"files": dl_manager.iter_archive(archive), "filepath": _FILENAMES[self.config.name]},
|
| 115 |
)
|
| 116 |
]
|
| 117 |
|
| 118 |
+
def _generate_examples(self, files, filepath):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
_id = 0
|
| 120 |
+
for path, f in files:
|
| 121 |
+
if path == filepath:
|
| 122 |
+
data = json.loads(f.read().decode("utf-8"))
|
| 123 |
+
for d in data:
|
| 124 |
+
if self.config.name.startswith("tlc"):
|
| 125 |
+
yield _id, d
|
| 126 |
+
else:
|
| 127 |
+
yield _id, {"text": d}
|
| 128 |
+
_id += 1
|
| 129 |
+
break
|