update
Browse files- UTS_WTK_v1.py +55 -0
UTS_WTK_v1.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import datasets
|
| 3 |
+
|
| 4 |
+
_DESCRIPTION = """\
|
| 5 |
+
UTS_WTK_v1
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
_CITATION = """\
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
_BASE_URL = "https://huggingface.co/datasets/undertheseanlp/UTS_WTK_v1/raw/main/data/"
|
| 12 |
+
TRAIN_FILE = "train.txt"
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
class UTS_WTK_v1(datasets.GeneratorBasedBuilder):
|
| 16 |
+
def _info(self):
|
| 17 |
+
return datasets.DatasetInfo(
|
| 18 |
+
description=_DESCRIPTION,
|
| 19 |
+
features=datasets.Features(
|
| 20 |
+
{
|
| 21 |
+
"tokens": datasets.Value("string"),
|
| 22 |
+
"tags": datasets.Value("string"),
|
| 23 |
+
}
|
| 24 |
+
),
|
| 25 |
+
supervised_keys=None,
|
| 26 |
+
homepage=None,
|
| 27 |
+
citation=_CITATION,
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
def _split_generators(self, dl_manager):
|
| 31 |
+
"""Returns SplitGenerators."""
|
| 32 |
+
train_file = dl_manager.download(os.path.join(_BASE_URL, TRAIN_FILE))
|
| 33 |
+
# dev_file = dl_manager.download(os.path.join(DATA_PATH, "dev.txt"))
|
| 34 |
+
# test_file = dl_manager.download(os.path.join(DATA_PATH, "test.txt"))
|
| 35 |
+
data_files = {
|
| 36 |
+
"train": train_file,
|
| 37 |
+
# "dev": dev_file,
|
| 38 |
+
# "test": test_file,
|
| 39 |
+
}
|
| 40 |
+
splits = [
|
| 41 |
+
datasets.SplitGenerator(
|
| 42 |
+
name=datasets.Split.TRAIN, gen_kwargs={"filepath": data_files["train"]}
|
| 43 |
+
),
|
| 44 |
+
# datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": data_files["dev"]}),
|
| 45 |
+
# datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": data_files["test"]}),
|
| 46 |
+
]
|
| 47 |
+
return splits
|
| 48 |
+
|
| 49 |
+
def _generate_examples(self, filepath):
|
| 50 |
+
with open(filepath, encoding="utf-8") as f:
|
| 51 |
+
guid = 0
|
| 52 |
+
for line in f:
|
| 53 |
+
text = line.strip()
|
| 54 |
+
yield guid, {"text": text}
|
| 55 |
+
guid += 1
|