Datasets:
Upload pclue.py
Browse files
pclue.py
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding=utf-8
|
| 2 |
+
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
| 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 |
+
"""Pclue dataset."""
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
import json
|
| 19 |
+
|
| 20 |
+
import py7zr
|
| 21 |
+
|
| 22 |
+
import datasets
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
_CITATION = """https://github.com/CLUEbenchmark/pCLUE"""
|
| 26 |
+
|
| 27 |
+
_DESCRIPTION = """https://github.com/CLUEbenchmark/pCLUE"""
|
| 28 |
+
|
| 29 |
+
_HOMEPAGE = "https://github.com/CLUEbenchmark/pCLUE"
|
| 30 |
+
|
| 31 |
+
_LICENSE = "apache-2.0"
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
_URL = "https://huggingface.co/datasets/wbbbbb/pclue/resolve/main/pclue.7z"
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
class Pclue(datasets.GeneratorBasedBuilder):
|
| 38 |
+
"""Pclue Corpus dataset."""
|
| 39 |
+
|
| 40 |
+
VERSION = datasets.Version("1.0.0")
|
| 41 |
+
|
| 42 |
+
BUILDER_CONFIGS = [
|
| 43 |
+
datasets.BuilderConfig(name="pclue"),
|
| 44 |
+
]
|
| 45 |
+
|
| 46 |
+
def _info(self):
|
| 47 |
+
features = datasets.Features(
|
| 48 |
+
{
|
| 49 |
+
"input": datasets.Value("string"),
|
| 50 |
+
"target": datasets.Value("string"),
|
| 51 |
+
"type": datasets.Value("string"),
|
| 52 |
+
}
|
| 53 |
+
)
|
| 54 |
+
return datasets.DatasetInfo(
|
| 55 |
+
description=_DESCRIPTION,
|
| 56 |
+
features=features,
|
| 57 |
+
supervised_keys=None,
|
| 58 |
+
homepage=_HOMEPAGE,
|
| 59 |
+
license=_LICENSE,
|
| 60 |
+
citation=_CITATION,
|
| 61 |
+
)
|
| 62 |
+
|
| 63 |
+
def _split_generators(self, dl_manager):
|
| 64 |
+
"""Returns SplitGenerators."""
|
| 65 |
+
path = dl_manager.download_and_extract(_URL)
|
| 66 |
+
return [
|
| 67 |
+
datasets.SplitGenerator(
|
| 68 |
+
name=datasets.Split.TRAIN,
|
| 69 |
+
gen_kwargs={
|
| 70 |
+
"filepath": path+"train.json",
|
| 71 |
+
"split": "train",
|
| 72 |
+
},
|
| 73 |
+
),
|
| 74 |
+
datasets.SplitGenerator(
|
| 75 |
+
name=datasets.Split.TEST,
|
| 76 |
+
gen_kwargs={
|
| 77 |
+
"filepath": path+"test.json",
|
| 78 |
+
"split": "test",
|
| 79 |
+
},
|
| 80 |
+
),
|
| 81 |
+
datasets.SplitGenerator(
|
| 82 |
+
name=datasets.Split.VALIDATION,
|
| 83 |
+
gen_kwargs={
|
| 84 |
+
"filepath": path+"dev.json",
|
| 85 |
+
"split": "val",
|
| 86 |
+
},
|
| 87 |
+
),
|
| 88 |
+
]
|
| 89 |
+
|
| 90 |
+
def _generate_examples(self, filepath, split):
|
| 91 |
+
"""Yields examples."""
|
| 92 |
+
with open(filepath, encoding="utf-8") as f:
|
| 93 |
+
for idx, row in enumerate(f):
|
| 94 |
+
yield idx, json.load(row)
|
| 95 |
+
|