Upload 4 files
Browse files- .gitattributes +2 -0
- SciGraph.py +150 -0
- assign.json +3 -0
- class.json +8 -0
- paper_new.json +3 -0
.gitattributes
CHANGED
|
@@ -52,3 +52,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 52 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 53 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
| 54 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 52 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 53 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
| 54 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
| 55 |
+
assign.json filter=lfs diff=lfs merge=lfs -text
|
| 56 |
+
paper_new.json filter=lfs diff=lfs merge=lfs -text
|
SciGraph.py
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
"""
|
| 3 |
+
@Project : indexing
|
| 4 |
+
@File : SciGraph
|
| 5 |
+
@Email : yanyuchen@zju.edu.cn
|
| 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 |
+
# TODO: Add link to the official dataset URLs here
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
# TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
|
| 40 |
+
class SciGraph(datasets.GeneratorBasedBuilder):
|
| 41 |
+
"""TODO: Short description of my dataset."""
|
| 42 |
+
|
| 43 |
+
VERSION = datasets.Version("0.0.1")
|
| 44 |
+
|
| 45 |
+
BUILDER_CONFIGS = [
|
| 46 |
+
datasets.BuilderConfig(name="function", version=VERSION,
|
| 47 |
+
description="This part of my dataset covers extraction"),
|
| 48 |
+
datasets.BuilderConfig(name="topic", version=VERSION,
|
| 49 |
+
description="This part of my dataset covers generation")
|
| 50 |
+
]
|
| 51 |
+
|
| 52 |
+
DEFAULT_CONFIG_NAME = "function"
|
| 53 |
+
|
| 54 |
+
def _info(self):
|
| 55 |
+
with open('class.json', 'r') as f:
|
| 56 |
+
classes = list(json.load(f).keys())
|
| 57 |
+
if self.config.name == "function": # This is the name of the configuration selected in BUILDER_CONFIGS above
|
| 58 |
+
features = datasets.Features(
|
| 59 |
+
{
|
| 60 |
+
"id": datasets.Value("string"),
|
| 61 |
+
"abstract": datasets.Value("string"),
|
| 62 |
+
"label": datasets.features.ClassLabel(names=classes, num_classes=len(classes))
|
| 63 |
+
}
|
| 64 |
+
)
|
| 65 |
+
else:
|
| 66 |
+
features = datasets.Features(
|
| 67 |
+
{
|
| 68 |
+
"id": datasets.Value("string"),
|
| 69 |
+
"abstract": datasets.Value("string"),
|
| 70 |
+
"keywords": datasets.features.Sequence(datasets.Value("string"))
|
| 71 |
+
}
|
| 72 |
+
)
|
| 73 |
+
|
| 74 |
+
return datasets.DatasetInfo(
|
| 75 |
+
# This is the description that will appear on the datasets page.
|
| 76 |
+
description=_DESCRIPTION,
|
| 77 |
+
# This defines the different columns of the dataset and their types
|
| 78 |
+
features=features,
|
| 79 |
+
homepage=_HOMEPAGE,
|
| 80 |
+
# License for the dataset if available
|
| 81 |
+
license=_LICENSE,
|
| 82 |
+
# Citation for the dataset
|
| 83 |
+
citation=_CITATION,
|
| 84 |
+
)
|
| 85 |
+
|
| 86 |
+
def _split_generators(self, dl_manager):
|
| 87 |
+
|
| 88 |
+
return [
|
| 89 |
+
datasets.SplitGenerator(
|
| 90 |
+
name=datasets.Split.TRAIN,
|
| 91 |
+
# These kwargs will be passed to _generate_examples
|
| 92 |
+
gen_kwargs={
|
| 93 |
+
"split": "train",
|
| 94 |
+
},
|
| 95 |
+
),
|
| 96 |
+
datasets.SplitGenerator(
|
| 97 |
+
name=datasets.Split.TEST,
|
| 98 |
+
# These kwargs will be passed to _generate_examples
|
| 99 |
+
gen_kwargs={
|
| 100 |
+
"split": "test"
|
| 101 |
+
},
|
| 102 |
+
)
|
| 103 |
+
]
|
| 104 |
+
|
| 105 |
+
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
| 106 |
+
def _generate_examples(self, split):
|
| 107 |
+
if self.config.name == 'function':
|
| 108 |
+
with open('class.json', 'r') as f:
|
| 109 |
+
functions = list(json.load(f).keys())
|
| 110 |
+
data = pd.read_json('assign.json')
|
| 111 |
+
|
| 112 |
+
if split == 'train':
|
| 113 |
+
data = data.loc[data[functions].sum(axis=1) == 1]
|
| 114 |
+
data['label'] = [functions[row.tolist().index(1)] for index, row in data[functions].iterrows()]
|
| 115 |
+
data = data[['_id', 'abstract', 'label']]
|
| 116 |
+
for idx, row in data.iterrows():
|
| 117 |
+
yield idx, {
|
| 118 |
+
"id": row._id,
|
| 119 |
+
"abstract": row.abstract,
|
| 120 |
+
"label": row.label
|
| 121 |
+
}
|
| 122 |
+
elif split == 'test':
|
| 123 |
+
data = data.loc[data[functions].sum(axis=1) == 0]
|
| 124 |
+
data = data[['_id', 'abstract']]
|
| 125 |
+
for idx, row in data.iterrows():
|
| 126 |
+
yield idx, {
|
| 127 |
+
"id": row._id,
|
| 128 |
+
"abstract": row.abstract,
|
| 129 |
+
"label": -1
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
if self.config.name == 'topic':
|
| 133 |
+
data = pd.read_json('paper_new.json')
|
| 134 |
+
data = data.replace(to_replace=r'^\s*$', value=np.nan, regex=True).dropna(subset=['keywords'], axis=0)
|
| 135 |
+
|
| 136 |
+
train_data, test_data = train_test_split(data, test_size=0.1, random_state=42)
|
| 137 |
+
if split == 'train':
|
| 138 |
+
for idx, row in train_data.iterrows():
|
| 139 |
+
yield idx, {
|
| 140 |
+
"id": row._id,
|
| 141 |
+
"abstract": row.abstract,
|
| 142 |
+
"keywords": row.keywords.split('#%#')
|
| 143 |
+
}
|
| 144 |
+
elif split == 'test':
|
| 145 |
+
for idx, row in test_data.iterrows():
|
| 146 |
+
yield idx, {
|
| 147 |
+
"id": row._id,
|
| 148 |
+
"abstract": row.abstract,
|
| 149 |
+
"keywords": row.keywords.split('#%#')
|
| 150 |
+
}
|
assign.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5ec51303427147a084ede88bc2efebb585bbea5b1f51677548b025611ee2aa95
|
| 3 |
+
size 788137793
|
class.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"综述与进展": ["综述", "进展", "现状", "展望", "启示", "趋势", "前景"],
|
| 3 |
+
"论证与对比": ["说明", "评价", "评估", "分析", "对比", "比较", "改善", "验证", "改进"],
|
| 4 |
+
"思考与探讨": ["思考", "讨论", "探讨", "意义", "浅谈", "探析", "建议", "探索", "探究"],
|
| 5 |
+
"原理与计算": ["基础", "计算", "理论", "原理", "求解", "规律", "理念", "性质", "机制"],
|
| 6 |
+
"技术与方法": ["技术", "方法", "算法", "模型", "思路", "对策", "措施", "策略", "方式"],
|
| 7 |
+
"设计与应用": ["设计", "实现", "应用", "实践", "方案", "案例", "运用", "制作", "研发", "研制"]
|
| 8 |
+
}
|
paper_new.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e0236f2328a844ebc7caa7f4209685d55041d9a9621c89d9efc39e8f0653c3ce
|
| 3 |
+
size 885375447
|