Upload Quintuple.py
Browse files- Quintuple.py +84 -0
Quintuple.py
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""Co-occurrenceCitationQuintuple"""
|
2 |
+
|
3 |
+
import json
|
4 |
+
|
5 |
+
import datasets
|
6 |
+
from datasets.tasks import QuestionAnsweringExtractive
|
7 |
+
|
8 |
+
|
9 |
+
logger = datasets.logging.get_logger(__name__)
|
10 |
+
|
11 |
+
|
12 |
+
_CITATION = """\
|
13 |
+
@inproceedings{xu2023exploring,
|
14 |
+
title={Exploring and Verbalizing Academic Ideas by Concept Co-occurrence},
|
15 |
+
author={Xu, Yi and Sheng, Shuqian and Xue, Bo and Fu, Luoyi and Wang, Xinbing and Zhou, Chenghu},
|
16 |
+
booktitle={Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (ACL)},
|
17 |
+
year={2023}
|
18 |
+
}
|
19 |
+
"""
|
20 |
+
|
21 |
+
_DESCRIPTION = """\
|
22 |
+
It is the official Co-occurrence Citation Quintuple dataset of paper \
|
23 |
+
Exploring and Verbalizing Academic Ideas by Concept Co-occurrence.
|
24 |
+
"""
|
25 |
+
|
26 |
+
_URL = "https://github.com/xyjigsaw/Kiscovery"
|
27 |
+
|
28 |
+
|
29 |
+
class QuintupleConfig(datasets.BuilderConfig):
|
30 |
+
"""BuilderConfig for Quintuple."""
|
31 |
+
|
32 |
+
def __init__(self, **kwargs):
|
33 |
+
"""BuilderConfig for Quintuple.
|
34 |
+
Args:
|
35 |
+
**kwargs: keyword arguments forwarded to super.
|
36 |
+
"""
|
37 |
+
super(QuintupleConfig, self).__init__(**kwargs)
|
38 |
+
|
39 |
+
|
40 |
+
class Quintuple(datasets.GeneratorBasedBuilder):
|
41 |
+
"""Quintuple: V202306"""
|
42 |
+
|
43 |
+
BUILDER_CONFIGS = [
|
44 |
+
QuintupleConfig(
|
45 |
+
name="plain_text",
|
46 |
+
version=datasets.Version("202306", ""),
|
47 |
+
description="Plain text",
|
48 |
+
),
|
49 |
+
]
|
50 |
+
|
51 |
+
def _info(self):
|
52 |
+
return datasets.DatasetInfo(
|
53 |
+
description=_DESCRIPTION,
|
54 |
+
features=datasets.Features(
|
55 |
+
{
|
56 |
+
"c1": datasets.Value("string"),
|
57 |
+
"c2": datasets.Value("string"),
|
58 |
+
"p": datasets.Value("string"),
|
59 |
+
"p1": datasets.Value("string"),
|
60 |
+
"p2": datasets.Value("string"),
|
61 |
+
}
|
62 |
+
),
|
63 |
+
# No default supervised_keys (as we have to pass both question
|
64 |
+
# and context as input).
|
65 |
+
supervised_keys=None,
|
66 |
+
homepage="https://github.com/xyjigsaw/Kiscovery",
|
67 |
+
citation=_CITATION,
|
68 |
+
)
|
69 |
+
|
70 |
+
def _generate_examples(self, filepath):
|
71 |
+
"""This function returns the examples in the raw (text) form."""
|
72 |
+
logger.info("generating examples from = %s", filepath)
|
73 |
+
key = 0
|
74 |
+
with open(filepath, encoding="utf-8") as f:
|
75 |
+
all_text = json.load(f)
|
76 |
+
for item in all_text:
|
77 |
+
yield key, {
|
78 |
+
"c1": item[0],
|
79 |
+
"c2": item[1],
|
80 |
+
"p": item[2],
|
81 |
+
"p1": item[3],
|
82 |
+
"p2": item[4],
|
83 |
+
}
|
84 |
+
key += 1
|