@nahisaho/satori 0.17.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,298 @@
1
+ ---
2
+ name: scientific-semantic-scholar
3
+ description: |
4
+ Semantic Scholar 学術グラフスキル。Semantic Scholar Academic
5
+ Graph API による論文検索・著者プロファイル・引用グラフ・
6
+ 推薦・TLDR 要約。ToolUniverse 連携: semantic_scholar。
7
+ tu_tools:
8
+ - key: semantic_scholar
9
+ name: Semantic Scholar
10
+ description: 学術論文検索・引用解析・著者プロファイル
11
+ ---
12
+
13
+ # Scientific Semantic Scholar
14
+
15
+ Semantic Scholar Academic Graph API を活用した学術論文検索・
16
+ 引用ネットワーク解析・著者プロファイル・論文推薦パイプライン
17
+ を提供する。
18
+
19
+ ## When to Use
20
+
21
+ - 学術論文を高精度で検索するとき
22
+ - 引用・被引用ネットワークを解析するとき
23
+ - 著者の h-index・論文数・研究領域を調べるとき
24
+ - 関連論文の推薦を受けるとき
25
+ - TLDR (自動要約) を取得するとき
26
+ - 特定分野の引用傾向を分析するとき
27
+ - PubMed/OpenAlex 以外の学術検索エンジンを使うとき
28
+
29
+ ---
30
+
31
+ ## Quick Start
32
+
33
+ ## 1. 論文検索
34
+
35
+ ```python
36
+ import requests
37
+ import pandas as pd
38
+
39
+ S2_BASE = "https://api.semanticscholar.org/graph/v1"
40
+ S2_HEADERS = {} # API key: {"x-api-key": "YOUR_KEY"}
41
+
42
+
43
+ def semantic_scholar_search(query, limit=50,
44
+ year_range=None,
45
+ fields_of_study=None):
46
+ """
47
+ Semantic Scholar — 論文検索。
48
+
49
+ Parameters:
50
+ query: str — 検索クエリ
51
+ limit: int — 最大結果数
52
+ year_range: str — 年範囲 (例: "2020-2024")
53
+ fields_of_study: list[str] — 分野フィルタ
54
+ """
55
+ url = f"{S2_BASE}/paper/search"
56
+ params = {
57
+ "query": query,
58
+ "limit": min(limit, 100),
59
+ "fields": ("paperId,title,year,citationCount,"
60
+ "influentialCitationCount,authors,"
61
+ "journal,tldr,openAccessPdf,fieldsOfStudy"),
62
+ }
63
+ if year_range:
64
+ params["year"] = year_range
65
+ if fields_of_study:
66
+ params["fieldsOfStudy"] = ",".join(fields_of_study)
67
+
68
+ resp = requests.get(url, params=params,
69
+ headers=S2_HEADERS, timeout=30)
70
+ resp.raise_for_status()
71
+ data = resp.json()
72
+
73
+ results = []
74
+ for p in data.get("data", []):
75
+ authors = [a.get("name", "") for a in p.get("authors", [])]
76
+ tldr_text = ""
77
+ if p.get("tldr"):
78
+ tldr_text = p["tldr"].get("text", "")
79
+ results.append({
80
+ "paper_id": p.get("paperId", ""),
81
+ "title": p.get("title", ""),
82
+ "year": p.get("year"),
83
+ "citation_count": p.get("citationCount", 0),
84
+ "influential_citations": p.get(
85
+ "influentialCitationCount", 0),
86
+ "authors": "; ".join(authors[:5]),
87
+ "journal": (p.get("journal") or {}).get("name", ""),
88
+ "fields": ", ".join(p.get("fieldsOfStudy") or []),
89
+ "tldr": tldr_text[:300],
90
+ "pdf_url": (p.get("openAccessPdf") or {}).get("url", ""),
91
+ })
92
+
93
+ df = pd.DataFrame(results)
94
+ print(f"Semantic Scholar: {len(df)} papers "
95
+ f"(query='{query}')")
96
+ return df
97
+
98
+
99
+ def semantic_scholar_get_paper(paper_id):
100
+ """
101
+ Semantic Scholar — 論文詳細取得。
102
+
103
+ Parameters:
104
+ paper_id: str — S2 Paper ID / DOI / ArXiv ID
105
+ """
106
+ url = f"{S2_BASE}/paper/{paper_id}"
107
+ params = {
108
+ "fields": ("paperId,title,year,abstract,citationCount,"
109
+ "influentialCitationCount,authors,references,"
110
+ "citations,journal,tldr,openAccessPdf,"
111
+ "fieldsOfStudy,publicationDate,venue"),
112
+ }
113
+ resp = requests.get(url, params=params,
114
+ headers=S2_HEADERS, timeout=30)
115
+ resp.raise_for_status()
116
+ return resp.json()
117
+ ```
118
+
119
+ ## 2. 著者プロファイル・引用解析
120
+
121
+ ```python
122
+ def semantic_scholar_author(author_id, paper_limit=100):
123
+ """
124
+ Semantic Scholar — 著者プロファイル取得。
125
+
126
+ Parameters:
127
+ author_id: str — S2 Author ID
128
+ paper_limit: int — 取得論文数上限
129
+ """
130
+ url = f"{S2_BASE}/author/{author_id}"
131
+ params = {
132
+ "fields": ("authorId,name,affiliations,homepage,"
133
+ "paperCount,citationCount,hIndex"),
134
+ }
135
+ resp = requests.get(url, params=params,
136
+ headers=S2_HEADERS, timeout=30)
137
+ resp.raise_for_status()
138
+ profile = resp.json()
139
+
140
+ # 論文一覧
141
+ papers_url = f"{S2_BASE}/author/{author_id}/papers"
142
+ p_params = {
143
+ "fields": "paperId,title,year,citationCount,venue",
144
+ "limit": min(paper_limit, 1000),
145
+ }
146
+ p_resp = requests.get(papers_url, params=p_params,
147
+ headers=S2_HEADERS, timeout=30)
148
+ p_resp.raise_for_status()
149
+
150
+ papers = []
151
+ for p in p_resp.json().get("data", []):
152
+ papers.append({
153
+ "paper_id": p.get("paperId", ""),
154
+ "title": p.get("title", ""),
155
+ "year": p.get("year"),
156
+ "citations": p.get("citationCount", 0),
157
+ "venue": p.get("venue", ""),
158
+ })
159
+
160
+ papers_df = pd.DataFrame(papers)
161
+
162
+ print(f"Author {profile.get('name', '')}: "
163
+ f"h-index={profile.get('hIndex', 0)}, "
164
+ f"{profile.get('paperCount', 0)} papers, "
165
+ f"{profile.get('citationCount', 0)} citations")
166
+ return profile, papers_df
167
+ ```
168
+
169
+ ## 3. 引用ネットワーク・影響度分析
170
+
171
+ ```python
172
+ def semantic_scholar_citation_graph(paper_id,
173
+ direction="both",
174
+ limit=100):
175
+ """
176
+ Semantic Scholar — 引用グラフ取得。
177
+
178
+ Parameters:
179
+ paper_id: str — S2 Paper ID
180
+ direction: str — "citations", "references", "both"
181
+ limit: int — 各方向の上限
182
+ """
183
+ graphs = {}
184
+ fields = "paperId,title,year,citationCount,authors"
185
+
186
+ if direction in ("citations", "both"):
187
+ url = f"{S2_BASE}/paper/{paper_id}/citations"
188
+ resp = requests.get(url, params={"fields": fields,
189
+ "limit": limit},
190
+ headers=S2_HEADERS, timeout=30)
191
+ resp.raise_for_status()
192
+ cites = []
193
+ for c in resp.json().get("data", []):
194
+ cp = c.get("citingPaper", {})
195
+ cites.append({
196
+ "paper_id": cp.get("paperId", ""),
197
+ "title": cp.get("title", ""),
198
+ "year": cp.get("year"),
199
+ "citations": cp.get("citationCount", 0),
200
+ })
201
+ graphs["citations"] = pd.DataFrame(cites)
202
+
203
+ if direction in ("references", "both"):
204
+ url = f"{S2_BASE}/paper/{paper_id}/references"
205
+ resp = requests.get(url, params={"fields": fields,
206
+ "limit": limit},
207
+ headers=S2_HEADERS, timeout=30)
208
+ resp.raise_for_status()
209
+ refs = []
210
+ for r in resp.json().get("data", []):
211
+ rp = r.get("citedPaper", {})
212
+ refs.append({
213
+ "paper_id": rp.get("paperId", ""),
214
+ "title": rp.get("title", ""),
215
+ "year": rp.get("year"),
216
+ "citations": rp.get("citationCount", 0),
217
+ })
218
+ graphs["references"] = pd.DataFrame(refs)
219
+
220
+ for k, v in graphs.items():
221
+ print(f" {k}: {len(v)} papers")
222
+ return graphs
223
+ ```
224
+
225
+ ## 4. 学術文献統合パイプライン
226
+
227
+ ```python
228
+ def semantic_scholar_pipeline(query, year_range=None,
229
+ output_dir="results"):
230
+ """
231
+ Semantic Scholar 統合パイプライン。
232
+
233
+ Parameters:
234
+ query: str — 検索クエリ
235
+ year_range: str — 年範囲
236
+ output_dir: str — 出力ディレクトリ
237
+ """
238
+ from pathlib import Path
239
+ output_dir = Path(output_dir)
240
+ output_dir.mkdir(parents=True, exist_ok=True)
241
+
242
+ # 1) 論文検索
243
+ papers = semantic_scholar_search(query,
244
+ year_range=year_range)
245
+ papers.to_csv(output_dir / "papers.csv", index=False)
246
+
247
+ # 2) トップ被引用論文の引用グラフ
248
+ if not papers.empty:
249
+ top = papers.sort_values("citation_count",
250
+ ascending=False).iloc[0]
251
+ pid = top["paper_id"]
252
+ graphs = semantic_scholar_citation_graph(pid)
253
+ for k, df in graphs.items():
254
+ df.to_csv(output_dir / f"{k}.csv", index=False)
255
+
256
+ # 3) 年次引用傾向
257
+ if not papers.empty and "year" in papers.columns:
258
+ yearly = papers.groupby("year").agg(
259
+ papers_count=("paper_id", "count"),
260
+ total_citations=("citation_count", "sum"),
261
+ avg_citations=("citation_count", "mean"),
262
+ ).reset_index()
263
+ yearly.to_csv(output_dir / "yearly_trend.csv",
264
+ index=False)
265
+
266
+ print(f"Semantic Scholar pipeline: {output_dir}")
267
+ return {"papers": papers}
268
+ ```
269
+
270
+ ---
271
+
272
+ ## ToolUniverse 連携
273
+
274
+ | TU Key | ツール名 | 連携内容 |
275
+ |--------|---------|---------|
276
+ | `semantic_scholar` | Semantic Scholar | 論文検索・引用解析・著者・TLDR |
277
+
278
+ ## パイプライン統合
279
+
280
+ ```
281
+ literature-search → semantic-scholar → deep-research
282
+ (PubMed/NCBI) (Academic Graph API) (knowledge synthesis)
283
+ │ │ ↓
284
+ crossref-metadata ─────┘ citation-checker
285
+ (DOI/metadata) │ (引用品質検証)
286
+
287
+ gene-expression-transcriptomics
288
+ (論文引用データからの解析)
289
+ ```
290
+
291
+ ## パイプライン出力
292
+
293
+ | ファイル | 説明 | 次スキル |
294
+ |---------|------|---------|
295
+ | `results/papers.csv` | 論文検索結果 | → deep-research |
296
+ | `results/citations.csv` | 被引用論文 | → citation-checker |
297
+ | `results/references.csv` | 引用論文 | → meta-analysis |
298
+ | `results/yearly_trend.csv` | 年次引用傾向 | → bibliometrics |