albertvillanova HF staff commited on
Commit
dc7966d
1 Parent(s): 6f93b0f

Remove deprecated tasks

Browse files

This dataset uses `tasks`, which are deprecated and will raise an error after the next major release of `datasets`. See: https://github.com/huggingface/datasets/pull/6999

Files changed (1) hide show
  1. fdRE.py +103 -105
fdRE.py CHANGED
@@ -1,106 +1,104 @@
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
-
16
- import os
17
-
18
- import datasets
19
- from datasets.tasks import TextClassification
20
-
21
-
22
- _CITATION = """\
23
- @author tianjie
24
- fdRE
25
- Chinese
26
- }
27
- """
28
-
29
- _DESCRIPTION = """\
30
- fdRE是一个中文的轴承故障诊断领域的关系抽取数据集
31
- 该数据集主要包含正向从属、反向从属以及无关三类标签
32
- """
33
-
34
- _URL = "https://huggingface.co/datasets/leonadase/fdRE/resolve/main/fdRE.zip"
35
-
36
-
37
- class SemEval2010Task8(datasets.GeneratorBasedBuilder):
38
- """The SemEval-2010 Task 8 focuses on Multi-way classification of semantic relations between pairs of nominals.
39
- The task was designed to compare different approaches to semantic relation classification
40
- and to provide a standard testbed for future research."""
41
-
42
- VERSION = datasets.Version("1.0.0")
43
-
44
- def _info(self):
45
- return datasets.DatasetInfo(
46
- # This is the description that will appear on the datasets page.
47
- description=_DESCRIPTION,
48
- # This defines the different columns of the dataset and their types
49
- features=datasets.Features(
50
- {
51
- "sentence": datasets.Value("string"),
52
- "relation": datasets.ClassLabel(
53
- names=[
54
- "Part_Of(E1,E2)",
55
- "Part_Of(E2,E1)",
56
- "Other",
57
- ]
58
- ),
59
- }
60
- ),
61
- # If there's a common (input, target) tuple from the features,
62
- # specify them here. They'll be used if as_supervised=True in
63
- # builder.as_dataset.
64
- supervised_keys=datasets.info.SupervisedKeysData(input="sentence", output="relation"),
65
- # Homepage of the dataset for documentation
66
- citation=_CITATION,
67
- task_templates=[TextClassification(text_column="sentence", label_column="relation")],
68
- )
69
-
70
- def _split_generators(self, dl_manager):
71
- """Returns SplitGenerators."""
72
- # dl_manager is a datasets.download.DownloadManager that can be used to
73
- # download and extract URLs
74
- dl_dir = dl_manager.download_and_extract(_URL)
75
- # data_dir = os.path.join(dl_dir, "fdRE")
76
- data_dir = dl_dir
77
- return [
78
- datasets.SplitGenerator(
79
- name=datasets.Split.TRAIN,
80
- # These kwargs will be passed to _generate_examples
81
- gen_kwargs={
82
- "filepath": os.path.join(data_dir, "train.txt"),
83
- },
84
- ),
85
- datasets.SplitGenerator(
86
- name=datasets.Split.TEST,
87
- gen_kwargs={
88
- "filepath": os.path.join(data_dir, "test.txt"),
89
- },
90
- ),
91
- ]
92
-
93
- def _generate_examples(self, filepath):
94
- """Yields examples."""
95
- with open(filepath, encoding="utf-8") as file:
96
- lines = file.readlines()
97
- num_lines_per_sample = 4
98
-
99
- for i in range(0, len(lines), num_lines_per_sample):
100
- idx = int(lines[i].split("\t")[0])
101
- sentence = lines[i].split("\t")[1][1:-2] # remove " at the start and "\n at the end
102
- relation = lines[i + 1][:-1] # remove \n at the end
103
- yield idx, {
104
- "sentence": sentence,
105
- "relation": relation,
106
  }
 
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
+
16
+ import os
17
+
18
+ import datasets
19
+
20
+
21
+ _CITATION = """\
22
+ @author tianjie
23
+ fdRE
24
+ Chinese
25
+ }
26
+ """
27
+
28
+ _DESCRIPTION = """\
29
+ fdRE是一个中文的轴承故障诊断领域的关系抽取数据集
30
+ 该数据集主要包含正向从属、反向从属以及无关三类标签
31
+ """
32
+
33
+ _URL = "https://huggingface.co/datasets/leonadase/fdRE/resolve/main/fdRE.zip"
34
+
35
+
36
+ class SemEval2010Task8(datasets.GeneratorBasedBuilder):
37
+ """The SemEval-2010 Task 8 focuses on Multi-way classification of semantic relations between pairs of nominals.
38
+ The task was designed to compare different approaches to semantic relation classification
39
+ and to provide a standard testbed for future research."""
40
+
41
+ VERSION = datasets.Version("1.0.0")
42
+
43
+ def _info(self):
44
+ return datasets.DatasetInfo(
45
+ # This is the description that will appear on the datasets page.
46
+ description=_DESCRIPTION,
47
+ # This defines the different columns of the dataset and their types
48
+ features=datasets.Features(
49
+ {
50
+ "sentence": datasets.Value("string"),
51
+ "relation": datasets.ClassLabel(
52
+ names=[
53
+ "Part_Of(E1,E2)",
54
+ "Part_Of(E2,E1)",
55
+ "Other",
56
+ ]
57
+ ),
58
+ }
59
+ ),
60
+ # If there's a common (input, target) tuple from the features,
61
+ # specify them here. They'll be used if as_supervised=True in
62
+ # builder.as_dataset.
63
+ supervised_keys=datasets.info.SupervisedKeysData(input="sentence", output="relation"),
64
+ # Homepage of the dataset for documentation
65
+ citation=_CITATION,
66
+ )
67
+
68
+ def _split_generators(self, dl_manager):
69
+ """Returns SplitGenerators."""
70
+ # dl_manager is a datasets.download.DownloadManager that can be used to
71
+ # download and extract URLs
72
+ dl_dir = dl_manager.download_and_extract(_URL)
73
+ # data_dir = os.path.join(dl_dir, "fdRE")
74
+ data_dir = dl_dir
75
+ return [
76
+ datasets.SplitGenerator(
77
+ name=datasets.Split.TRAIN,
78
+ # These kwargs will be passed to _generate_examples
79
+ gen_kwargs={
80
+ "filepath": os.path.join(data_dir, "train.txt"),
81
+ },
82
+ ),
83
+ datasets.SplitGenerator(
84
+ name=datasets.Split.TEST,
85
+ gen_kwargs={
86
+ "filepath": os.path.join(data_dir, "test.txt"),
87
+ },
88
+ ),
89
+ ]
90
+
91
+ def _generate_examples(self, filepath):
92
+ """Yields examples."""
93
+ with open(filepath, encoding="utf-8") as file:
94
+ lines = file.readlines()
95
+ num_lines_per_sample = 4
96
+
97
+ for i in range(0, len(lines), num_lines_per_sample):
98
+ idx = int(lines[i].split("\t")[0])
99
+ sentence = lines[i].split("\t")[1][1:-2] # remove " at the start and "\n at the end
100
+ relation = lines[i + 1][:-1] # remove \n at the end
101
+ yield idx, {
102
+ "sentence": sentence,
103
+ "relation": relation,
 
 
104
  }