|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
import datasets
|
|
from datasets.tasks import TextClassification
|
|
|
|
|
|
_CITATION = """\
|
|
@author tianjie
|
|
fdRE
|
|
Chinese
|
|
}
|
|
"""
|
|
|
|
_DESCRIPTION = """\
|
|
fdRE是一个中文的轴承故障诊断领域的关系抽取数据集
|
|
该数据集主要包含正向从属、反向从属以及无关三类标签
|
|
"""
|
|
|
|
_URL = "https://huggingface.co/datasets/leonadase/fdRE/resolve/main/fdRE.zip"
|
|
|
|
|
|
class SemEval2010Task8(datasets.GeneratorBasedBuilder):
|
|
"""The SemEval-2010 Task 8 focuses on Multi-way classification of semantic relations between pairs of nominals.
|
|
The task was designed to compare different approaches to semantic relation classification
|
|
and to provide a standard testbed for future research."""
|
|
|
|
VERSION = datasets.Version("1.0.0")
|
|
|
|
def _info(self):
|
|
return datasets.DatasetInfo(
|
|
|
|
description=_DESCRIPTION,
|
|
|
|
features=datasets.Features(
|
|
{
|
|
"sentence": datasets.Value("string"),
|
|
"relation": datasets.ClassLabel(
|
|
names=[
|
|
"Part_Of(E1,E2)",
|
|
"Part_Of(E2,E1)",
|
|
"Other",
|
|
]
|
|
),
|
|
}
|
|
),
|
|
|
|
|
|
|
|
supervised_keys=datasets.info.SupervisedKeysData(input="sentence", output="relation"),
|
|
|
|
citation=_CITATION,
|
|
task_templates=[TextClassification(text_column="sentence", label_column="relation")],
|
|
)
|
|
|
|
def _split_generators(self, dl_manager):
|
|
"""Returns SplitGenerators."""
|
|
|
|
|
|
dl_dir = dl_manager.download_and_extract(_URL)
|
|
|
|
data_dir = dl_dir
|
|
return [
|
|
datasets.SplitGenerator(
|
|
name=datasets.Split.TRAIN,
|
|
|
|
gen_kwargs={
|
|
"filepath": os.path.join(data_dir, "train.txt"),
|
|
},
|
|
),
|
|
datasets.SplitGenerator(
|
|
name=datasets.Split.TEST,
|
|
gen_kwargs={
|
|
"filepath": os.path.join(data_dir, "test.txt"),
|
|
},
|
|
),
|
|
]
|
|
|
|
def _generate_examples(self, filepath):
|
|
"""Yields examples."""
|
|
with open(filepath, encoding="utf-8") as file:
|
|
lines = file.readlines()
|
|
num_lines_per_sample = 4
|
|
|
|
for i in range(0, len(lines), num_lines_per_sample):
|
|
idx = int(lines[i].split("\t")[0])
|
|
sentence = lines[i].split("\t")[1][1:-2]
|
|
relation = lines[i + 1][:-1]
|
|
yield idx, {
|
|
"sentence": sentence,
|
|
"relation": relation,
|
|
} |