Commit
·
f2bfe68
1
Parent(s):
e3304a2
Update parquet files
Browse files
README.md
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
---
|
2 |
-
license: mit
|
3 |
-
---
|
|
|
|
|
|
|
|
SciGraph.py
DELETED
@@ -1,162 +0,0 @@
|
|
1 |
-
# -*- coding: utf-8 -*-
|
2 |
-
"""
|
3 |
-
@Project : indexing
|
4 |
-
@File : SciGraph
|
5 |
-
@Email : [email protected]
|
6 |
-
@Author : Yan Yuchen
|
7 |
-
@Time : 2023/3/9 12:53
|
8 |
-
"""
|
9 |
-
import json
|
10 |
-
import datasets
|
11 |
-
import pandas as pd
|
12 |
-
import numpy as np
|
13 |
-
from sklearn.model_selection import train_test_split
|
14 |
-
|
15 |
-
|
16 |
-
_CITATION = """\
|
17 |
-
@InProceedings{yan-EtAl:2022:Poster,
|
18 |
-
author = {Yuchen Yan and Chong Chen},
|
19 |
-
title = {SciGraph: A Knowledge Graph Constructed by Function and Topic Annotation of Scientific Papers},
|
20 |
-
booktitle = {3rd Workshop on Extraction and Evaluation of Knowledge Entities from Scientific Documents (EEKE2022), June 20-24, 2022, Cologne, Germany and Online},
|
21 |
-
month = {June},
|
22 |
-
year = {2022},
|
23 |
-
address = {Beijing, China},
|
24 |
-
url = {https://ceur-ws.org/Vol-3210/paper16.pdf}
|
25 |
-
}
|
26 |
-
"""
|
27 |
-
|
28 |
-
_DESCRIPTION = """\
|
29 |
-
"""
|
30 |
-
|
31 |
-
_HOMEPAGE = ""
|
32 |
-
|
33 |
-
# The license information was obtained from https://github.com/boudinfl/ake-datasets as the dataset shared over here is taken from here
|
34 |
-
_LICENSE = ""
|
35 |
-
|
36 |
-
_URLS = {
|
37 |
-
'classes': 'class.json',
|
38 |
-
'function': 'assign.json',
|
39 |
-
'topic': 'paper_new.json'
|
40 |
-
}
|
41 |
-
|
42 |
-
# TODO: Add link to the official dataset URLs here
|
43 |
-
|
44 |
-
|
45 |
-
# TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
|
46 |
-
class SciGraph(datasets.GeneratorBasedBuilder):
|
47 |
-
"""TODO: Short description of my dataset."""
|
48 |
-
|
49 |
-
VERSION = datasets.Version("0.0.1")
|
50 |
-
|
51 |
-
BUILDER_CONFIGS = [
|
52 |
-
datasets.BuilderConfig(name="function", version=VERSION,
|
53 |
-
description="This part of my dataset covers extraction"),
|
54 |
-
datasets.BuilderConfig(name="topic", version=VERSION,
|
55 |
-
description="This part of my dataset covers generation")
|
56 |
-
]
|
57 |
-
|
58 |
-
DEFAULT_CONFIG_NAME = "function"
|
59 |
-
|
60 |
-
def _info(self):
|
61 |
-
classes = ['综述与进展', '论证与对比', '思考与探讨', '原理与计算', '技术与方法', '设计与应用']
|
62 |
-
if self.config.name == "function": # This is the name of the configuration selected in BUILDER_CONFIGS above
|
63 |
-
features = datasets.Features(
|
64 |
-
{
|
65 |
-
"id": datasets.Value("string"),
|
66 |
-
"abstract": datasets.Value("string"),
|
67 |
-
"label": datasets.features.ClassLabel(names=classes, num_classes=len(classes))
|
68 |
-
}
|
69 |
-
)
|
70 |
-
else:
|
71 |
-
features = datasets.Features(
|
72 |
-
{
|
73 |
-
"id": datasets.Value("string"),
|
74 |
-
"abstract": datasets.Value("string"),
|
75 |
-
"keywords": datasets.features.Sequence(datasets.Value("string"))
|
76 |
-
}
|
77 |
-
)
|
78 |
-
|
79 |
-
return datasets.DatasetInfo(
|
80 |
-
# This is the description that will appear on the datasets page.
|
81 |
-
description=_DESCRIPTION,
|
82 |
-
# This defines the different columns of the dataset and their types
|
83 |
-
features=features,
|
84 |
-
homepage=_HOMEPAGE,
|
85 |
-
# License for the dataset if available
|
86 |
-
license=_LICENSE,
|
87 |
-
# Citation for the dataset
|
88 |
-
citation=_CITATION,
|
89 |
-
)
|
90 |
-
|
91 |
-
def _split_generators(self, dl_manager):
|
92 |
-
data_dir = dl_manager.download_and_extract(_URLS)
|
93 |
-
|
94 |
-
return [
|
95 |
-
datasets.SplitGenerator(
|
96 |
-
name=datasets.Split.TRAIN,
|
97 |
-
# These kwargs will be passed to _generate_examples
|
98 |
-
gen_kwargs={
|
99 |
-
"split": "train",
|
100 |
-
"classes": data_dir['classes'],
|
101 |
-
"function": data_dir['function'],
|
102 |
-
"topic": data_dir['topic']
|
103 |
-
},
|
104 |
-
),
|
105 |
-
datasets.SplitGenerator(
|
106 |
-
name=datasets.Split.TEST,
|
107 |
-
# These kwargs will be passed to _generate_examples
|
108 |
-
gen_kwargs={
|
109 |
-
"split": "test",
|
110 |
-
"classes": data_dir['classes'],
|
111 |
-
"function": data_dir['function'],
|
112 |
-
"topic": data_dir['topic']
|
113 |
-
},
|
114 |
-
)
|
115 |
-
]
|
116 |
-
|
117 |
-
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
118 |
-
def _generate_examples(self, split, classes, function, topic):
|
119 |
-
if self.config.name == 'function':
|
120 |
-
with open(classes, 'r') as f:
|
121 |
-
functions = list(json.load(f).keys())
|
122 |
-
data = pd.read_json(function)
|
123 |
-
data = data.loc[data[functions].sum(axis=1) == 1]
|
124 |
-
data['label'] = [functions[row.tolist().index(1)] for index, row in data[functions].iterrows()]
|
125 |
-
data = data[['_id', 'abstract', 'label']]
|
126 |
-
|
127 |
-
|
128 |
-
train_data, test_data = train_test_split(data, test_size=0.1, random_state=42)
|
129 |
-
if split == 'train':
|
130 |
-
for idx, row in train_data.iterrows():
|
131 |
-
yield idx, {
|
132 |
-
"id": row._id,
|
133 |
-
"abstract": row.abstract,
|
134 |
-
"label": row.label
|
135 |
-
}
|
136 |
-
elif split == 'test':
|
137 |
-
for idx, row in test_data.iterrows():
|
138 |
-
yield idx, {
|
139 |
-
"id": row._id,
|
140 |
-
"abstract": row.abstract,
|
141 |
-
"label": -1
|
142 |
-
}
|
143 |
-
|
144 |
-
if self.config.name == 'topic':
|
145 |
-
data = pd.read_json(topic)
|
146 |
-
data = data.replace(to_replace=r'^\s*$', value=np.nan, regex=True).dropna(subset=['keywords'], axis=0)
|
147 |
-
|
148 |
-
train_data, test_data = train_test_split(data, test_size=0.1, random_state=42)
|
149 |
-
if split == 'train':
|
150 |
-
for idx, row in train_data.iterrows():
|
151 |
-
yield idx, {
|
152 |
-
"id": row._id,
|
153 |
-
"abstract": row.abstract,
|
154 |
-
"keywords": row.keywords.split('#%#')
|
155 |
-
}
|
156 |
-
elif split == 'test':
|
157 |
-
for idx, row in test_data.iterrows():
|
158 |
-
yield idx, {
|
159 |
-
"id": row._id,
|
160 |
-
"abstract": row.abstract,
|
161 |
-
"keywords": row.keywords.split('#%#')
|
162 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class.json
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"综述与进展": ["综述", "进展", "现状", "展望", "启示", "趋势", "前景"],
|
3 |
-
"论证与对比": ["说明", "评价", "评估", "分析", "对比", "比较", "改善", "验证", "改进"],
|
4 |
-
"思考与探讨": ["思考", "讨论", "探讨", "意义", "浅谈", "探析", "建议", "探索", "探究"],
|
5 |
-
"原理与计算": ["基础", "计算", "理论", "原理", "求解", "规律", "理念", "性质", "机制"],
|
6 |
-
"技术与方法": ["技术", "方法", "算法", "模型", "思路", "对策", "措施", "策略", "方式"],
|
7 |
-
"设计与应用": ["设计", "实现", "应用", "实践", "方案", "案例", "运用", "制作", "研发", "研制"]
|
8 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
paper_new.json → function/sci_graph-test.parquet
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:65ea03c17c12d171c83c04e31b112adcdd3b391e29863371f073725981d0b2a1
|
3 |
+
size 160589528
|
assign.json → function/sci_graph-train.parquet
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c9bfd630991e623da7027cc0fb647487f4c93e904b282b281e6fab0b40664ffd
|
3 |
+
size 148823709
|
topic/sci_graph-test.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5f35489f681c885e9949bc960308f7067f75dcee1c4c819109315eb379f4558f
|
3 |
+
size 39012507
|
topic/sci_graph-train-00000-of-00002.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5746dc78d9dafcc02cd200d3752c3ca915ee48685cc6e6737ec34de2317e0b35
|
3 |
+
size 340860258
|
topic/sci_graph-train-00001-of-00002.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:70e88904205622142d981500f8f1f94a223c09535719594a98025849d8215b16
|
3 |
+
size 10141740
|