# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Semeval2018Task7 is a dataset that describes the first task on semantic relation extraction and classification in scientific paper abstracts"""
import glob
import datasets
import xml.dom.minidom
import xml.etree.ElementTree as ET
_CITATION = """\
@inproceedings{gabor-etal-2018-semeval,
title = "{S}em{E}val-2018 Task 7: Semantic Relation Extraction and Classification in Scientific Papers",
author = {G{\'a}bor, Kata and
Buscaldi, Davide and
Schumann, Anne-Kathrin and
QasemiZadeh, Behrang and
Zargayouna, Ha{\"\i}fa and
Charnois, Thierry},
booktitle = "Proceedings of the 12th International Workshop on Semantic Evaluation",
month = jun,
year = "2018",
address = "New Orleans, Louisiana",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/S18-1111",
doi = "10.18653/v1/S18-1111",
pages = "679--688",
abstract = "This paper describes the first task on semantic relation extraction and classification in
scientific paper abstracts at SemEval 2018. The challenge focuses on domain-specific semantic relations
and includes three different subtasks. The subtasks were designed so as to compare and quantify the
effect of different pre-processing steps on the relation classification results. We expect the task to
be relevant for a broad range of researchers working on extracting specialized knowledge from domain
corpora, for example but not limited to scientific or bio-medical information extraction. The task
attracted a total of 32 participants, with 158 submissions across different scenarios.",
}
"""
_DESCRIPTION = """\
This paper describes the first task on semantic relation extraction and classification in scientific paper
abstracts at SemEval 2018. The challenge focuses on domain-specific semantic relations and includes three
different subtasks. The subtasks were designed so as to compare and quantify the effect of different
pre-processing steps on the relation classification results. We expect the task to be relevant for a broad
range of researchers working on extracting specialized knowledge from domain corpora, for example but not
limited to scientific or bio-medical information extraction. The task attracted a total of 32 participants,
with 158 submissions across different scenarios.
"""
_HOMEPAGE = "https://github.com/gkata/SemEval2018Task7/tree/testing"
_LICENSE = ""
# Add link to the official dataset URLs here
# The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
_URLS = {
"Subtask_1_1": {
"train": {
"relations": "https://raw.githubusercontent.com/gkata/SemEval2018Task7/testing/1.1.relations.txt",
"text": "https://raw.githubusercontent.com/gkata/SemEval2018Task7/testing/1.1.text.xml",
},
"test": {
"relations": "https://raw.githubusercontent.com/gkata/SemEval2018Task7/testing/1.1.test.relations.txt",
"text": "https://raw.githubusercontent.com/gkata/SemEval2018Task7/testing/1.1.test.text.xml",
},
},
"Subtask_1_2": {
"train": {
"relations": "https://raw.githubusercontent.com/gkata/SemEval2018Task7/testing/1.2.relations.txt",
"text": "https://raw.githubusercontent.com/gkata/SemEval2018Task7/testing/1.2.text.xml",
},
"test": {
"relations": "https://raw.githubusercontent.com/gkata/SemEval2018Task7/testing/1.2.test.relations.txt",
"text": "https://raw.githubusercontent.com/gkata/SemEval2018Task7/testing/1.2.test.text.xml",
},
},
}
def all_text_nodes(root):
if root.text is not None:
yield root.text
for child in root:
if child.tail is not None:
yield child.tail
def reading_entity_data(ET_data_to_convert):
parsed_data = ET.tostring(ET_data_to_convert,"utf-8")
parsed_data= parsed_data.decode('utf8').replace("b\'","")
parsed_data= parsed_data.replace("