Basvoju commited on
Commit
fe5e5af
1 Parent(s): 757e86e

Update SemEval2018Task7.py

Browse files
Files changed (1) hide show
  1. SemEval2018Task7.py +20 -28
SemEval2018Task7.py CHANGED
@@ -15,7 +15,7 @@
15
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
  # See the License for the specific language governing permissions and
17
  # limitations under the License.
18
- """Semeval2018Task7 is a dataset that describes Semantic Relation Extraction and Classification in Scientific Papers"""
19
 
20
 
21
 
@@ -240,13 +240,10 @@ class Semeval2018Task7(datasets.GeneratorBasedBuilder):
240
  second_half_splits = second_half.split(",")
241
  size = len(second_half_splits)
242
 
243
- X = second_half_splits[0]
244
- Y = second_half_splits[1]
245
-
246
  relation = {
247
  "label": use_case,
248
- "arg1": X,
249
- "arg2": Y,
250
  "reverse": True if size == 3 else False
251
  }
252
  relations.append(relation)
@@ -255,31 +252,26 @@ class Semeval2018Task7(datasets.GeneratorBasedBuilder):
255
  root = doc2.getroot()
256
 
257
  for child in root:
258
- if child.attrib!= None:
259
- text_id = child.attrib
260
- else:
261
  continue
262
-
263
- if child.find("title")!=None:
264
- title = child.find("title").text
265
- child_abstract = child.find("abstract")
266
- else:
267
  continue
 
 
268
 
269
- if child_abstract!=None:
270
- prev=ET.tostring(child_abstract,"utf-8")
271
- prev= prev.decode('utf8').replace("b\'","")
272
- prev= prev.replace("<abstract>","")
273
- prev= prev.replace("</abstract>","")
274
- final_list= reading_entity_data(prev)
275
- else:
276
- continue
277
 
278
 
279
- yield text_id['id'], {
280
- "id": text_id['id'],
281
- "title": title,
282
- "abstract": final_list['abstract'],
283
- "entities": final_list['entities'],
284
- "relation": relations
285
  }
 
15
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
  # See the License for the specific language governing permissions and
17
  # limitations under the License.
18
+ """Semeval2018Task7 is a dataset that describes the first task on semantic relation extraction and classification in scientific paper abstracts"""
19
 
20
 
21
 
 
240
  second_half_splits = second_half.split(",")
241
  size = len(second_half_splits)
242
 
 
 
 
243
  relation = {
244
  "label": use_case,
245
+ "arg1": second_half_splits[0],
246
+ "arg2": second_half_splits[1],
247
  "reverse": True if size == 3 else False
248
  }
249
  relations.append(relation)
 
252
  root = doc2.getroot()
253
 
254
  for child in root:
255
+ if child.find("title")==None:
 
 
256
  continue
257
+ text_id = child.attrib
258
+
259
+ if child.find("abstract")==None:
 
 
260
  continue
261
+ title = child.find("title").text
262
+ child_abstract = child.find("abstract")
263
 
264
+ prev=ET.tostring(child_abstract,"utf-8")
265
+ prev= prev.decode('utf8').replace("b\'","")
266
+ prev= prev.replace("<abstract>","")
267
+ prev= prev.replace("</abstract>","")
268
+ final_list= reading_entity_data(prev)
 
 
 
269
 
270
 
271
+ yield text_id['id'], {
272
+ "id": text_id['id'],
273
+ "title": title,
274
+ "abstract": final_list['abstract'],
275
+ "entities": final_list['entities'],
276
+ "relation": relations
277
  }