Basvoju commited on
Commit
4eaa197
1 Parent(s): 21d8a8c

Update SemEval2018Task7.py

Browse files
Files changed (1) hide show
  1. SemEval2018Task7.py +25 -13
SemEval2018Task7.py CHANGED
@@ -76,7 +76,7 @@ _LICENSE = ""
76
  # The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
77
  # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
78
  _URLS = {
79
- "clean": {
80
  "train": {
81
  "relations": "https://raw.githubusercontent.com/gkata/SemEval2018Task7/testing/1.1.relations.txt",
82
  "text": "https://raw.githubusercontent.com/gkata/SemEval2018Task7/testing/1.1.text.xml",
@@ -86,7 +86,7 @@ _URLS = {
86
  "text": "https://raw.githubusercontent.com/gkata/SemEval2018Task7/testing/1.1.test.text.xml",
87
  },
88
  },
89
- "noisy": {
90
  "train": {
91
  "relations": "https://raw.githubusercontent.com/gkata/SemEval2018Task7/testing/1.2.relations.txt",
92
  "text": "https://raw.githubusercontent.com/gkata/SemEval2018Task7/testing/1.2.text.xml",
@@ -95,8 +95,8 @@ _URLS = {
95
  "relations": "https://raw.githubusercontent.com/gkata/SemEval2018Task7/testing/1.2.test.relations.txt",
96
  "text": "https://raw.githubusercontent.com/gkata/SemEval2018Task7/testing/1.2.test.text.xml",
97
  },
98
- }
99
-
100
  }
101
 
102
 
@@ -162,15 +162,16 @@ class Semeval2018Task7(datasets.GeneratorBasedBuilder):
162
  VERSION = datasets.Version("1.1.0")
163
 
164
  BUILDER_CONFIGS = [
165
- datasets.BuilderConfig(name="clean", version=VERSION,
166
  description="Relation classification on clean data"),
167
- datasets.BuilderConfig(name="noisy", version=VERSION,
168
  description="Relation classification on noisy data"),
 
169
  ]
170
- DEFAULT_CONFIG_NAME = "clean"
171
 
172
  def _info(self):
173
- class_labels = ["USAGE", "RESULT", "MODEL-FEATURE", "PART_WHOLE", "TOPIC", "COMPARE"]
174
  features = datasets.Features(
175
  {
176
  "id": datasets.Value("string"),
@@ -218,22 +219,33 @@ class Semeval2018Task7(datasets.GeneratorBasedBuilder):
218
  # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
219
  urls = _URLS[self.config.name]
220
  downloaded_files = dl_manager.download(urls)
221
- #print(downloaded_files)
222
 
223
  return [
224
  datasets.SplitGenerator(
225
  name=datasets.Split.TRAIN,
226
  # These kwargs will be passed to _generate_examples
227
  gen_kwargs={
228
- "relation_filepath": downloaded_files[datasets.Split.TRAIN]["relations"],
229
- "text_filepath": downloaded_files[datasets.Split.TRAIN]["text"],
 
230
  }
231
 
232
- )]
233
- # TODO: test split does not contain relations, how to do
 
 
 
 
 
 
 
234
 
 
 
235
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
236
  def _generate_examples(self, relation_filepath, text_filepath):
 
237
  # TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
238
  # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
239
  with open(relation_filepath, encoding="utf-8") as f:
 
76
  # The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
77
  # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
78
  _URLS = {
79
+ "Subtask_1_1": {
80
  "train": {
81
  "relations": "https://raw.githubusercontent.com/gkata/SemEval2018Task7/testing/1.1.relations.txt",
82
  "text": "https://raw.githubusercontent.com/gkata/SemEval2018Task7/testing/1.1.text.xml",
 
86
  "text": "https://raw.githubusercontent.com/gkata/SemEval2018Task7/testing/1.1.test.text.xml",
87
  },
88
  },
89
+ "Subtask_1_2": {
90
  "train": {
91
  "relations": "https://raw.githubusercontent.com/gkata/SemEval2018Task7/testing/1.2.relations.txt",
92
  "text": "https://raw.githubusercontent.com/gkata/SemEval2018Task7/testing/1.2.text.xml",
 
95
  "relations": "https://raw.githubusercontent.com/gkata/SemEval2018Task7/testing/1.2.test.relations.txt",
96
  "text": "https://raw.githubusercontent.com/gkata/SemEval2018Task7/testing/1.2.test.text.xml",
97
  },
98
+ },
99
+
100
  }
101
 
102
 
 
162
  VERSION = datasets.Version("1.1.0")
163
 
164
  BUILDER_CONFIGS = [
165
+ datasets.BuilderConfig(name="Subtask_1_1", version=VERSION,
166
  description="Relation classification on clean data"),
167
+ datasets.BuilderConfig(name="Subtask_1_2", version=VERSION,
168
  description="Relation classification on noisy data"),
169
+
170
  ]
171
+ DEFAULT_CONFIG_NAME = "Subtask_1_1"
172
 
173
  def _info(self):
174
+ class_labels = ["","USAGE", "RESULT", "MODEL-FEATURE", "PART_WHOLE", "TOPIC", "COMPARE"]
175
  features = datasets.Features(
176
  {
177
  "id": datasets.Value("string"),
 
219
  # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
220
  urls = _URLS[self.config.name]
221
  downloaded_files = dl_manager.download(urls)
222
+ print(downloaded_files)
223
 
224
  return [
225
  datasets.SplitGenerator(
226
  name=datasets.Split.TRAIN,
227
  # These kwargs will be passed to _generate_examples
228
  gen_kwargs={
229
+ "relation_filepath": downloaded_files['train']["relations"],
230
+ "text_filepath": downloaded_files['train']["text"],
231
+
232
  }
233
 
234
+ ),
235
+ datasets.SplitGenerator(
236
+ name=datasets.Split.TEST,
237
+ # These kwargs will be passed to _generate_examples
238
+ gen_kwargs={
239
+ "relation_filepath": downloaded_files['test']["relations"],
240
+ "text_filepath": downloaded_files['test']["text"],
241
+
242
+ }
243
 
244
+ )]
245
+
246
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
247
  def _generate_examples(self, relation_filepath, text_filepath):
248
+
249
  # TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
250
  # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
251
  with open(relation_filepath, encoding="utf-8") as f: