sci-paper-digest 1.0.0 → 1.0.1
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.
- package/README.zh.md +1 -1
- package/docs/DETAIL.md +1 -1
- package/lib/format.js +6 -4
- package/lib/source.js +79 -6
- package/package.json +1 -1
- package/skill/SKILL.md +25 -13
package/README.zh.md
CHANGED
package/docs/DETAIL.md
CHANGED
package/lib/format.js
CHANGED
|
@@ -47,12 +47,14 @@ export function formatDigest(paper, maxChars, warnings = []) {
|
|
|
47
47
|
lines.push('', 'warnings:')
|
|
48
48
|
for (const warning of allWarnings) lines.push(`- ${warning}`)
|
|
49
49
|
}
|
|
50
|
-
const budgetNote = paper.
|
|
51
|
-
?
|
|
52
|
-
:
|
|
50
|
+
const budgetNote = paper.coverage !== 'full'
|
|
51
|
+
? `当前只有${paper.coverage === 'abstract' ? '摘要' : '元数据'},不得给出全文级结论;需要全文请让用户补 PDF。`
|
|
52
|
+
: paper.stats.chars > maxChars
|
|
53
|
+
? `正文约 ${paper.stats.chars} 字符,本次只放入 ${maxChars};summary 中不要假装读过未提供部分。`
|
|
54
|
+
: '正文已完整放入上下文。'
|
|
53
55
|
lines.push(
|
|
54
56
|
'',
|
|
55
|
-
'【输出要求】按 `sci-paper-digest`
|
|
57
|
+
'【输出要求】按 `sci-paper-digest` 技能输出:先一句中文点题,再给 **中文:** / **English:** 各 3–5 句的双语速览段(格式与用户给的示例图一致);然后方法(3–5 条)、逐条结果(方法—研究对象—结果 + SCI English)、6–8 条可复用 SCI 表达模板、创新点与局限。用户要精读时再展开深读版。',
|
|
56
58
|
`【范围提示】${budgetNote}`,
|
|
57
59
|
)
|
|
58
60
|
return lines.join('\n')
|
package/lib/source.js
CHANGED
|
@@ -49,7 +49,16 @@ export async function loadPaper(source, options = {}) {
|
|
|
49
49
|
} else if (target.type === 'doi') {
|
|
50
50
|
document = await loadDoi(target.doi, warnings, timeoutMs)
|
|
51
51
|
} else {
|
|
52
|
-
|
|
52
|
+
try {
|
|
53
|
+
document = await loadUrl(target.url, warnings, timeoutMs)
|
|
54
|
+
} catch (error) {
|
|
55
|
+
// 出版社常对非浏览器请求返回 403;能认出 DOI/PII 就改用元数据与摘要兜底。
|
|
56
|
+
warnings.push(`网页抓取失败:${messageOf(error)}`)
|
|
57
|
+
const fallbackDoi = extractDoiFromUrl(target.url) ?? await doiFromPii(target.url, warnings, timeoutMs)
|
|
58
|
+
if (fallbackDoi === undefined) throw error
|
|
59
|
+
warnings.push(`改用 DOI ${fallbackDoi} 的元数据与摘要。`)
|
|
60
|
+
document = await loadDoi(fallbackDoi, warnings, timeoutMs)
|
|
61
|
+
}
|
|
53
62
|
}
|
|
54
63
|
|
|
55
64
|
let text = (document.text ?? '').trim()
|
|
@@ -57,10 +66,12 @@ export async function loadPaper(source, options = {}) {
|
|
|
57
66
|
text = document.meta.abstract.trim()
|
|
58
67
|
warnings.push('只拿到摘要文本,没有正文。')
|
|
59
68
|
}
|
|
60
|
-
if (text === '') warnings.push('没有拿到正文文字:可能只有元数据、需要登录,或页面被反爬拦截。')
|
|
61
69
|
|
|
62
70
|
const htmlMeta = document.meta ?? {}
|
|
63
|
-
|
|
71
|
+
let doi = htmlMeta.doi ?? document.doi ?? findDoi(text)
|
|
72
|
+
if ((doi === undefined || doi === '') && target.type === 'url') {
|
|
73
|
+
doi = await doiFromPii(target.url, warnings, timeoutMs)
|
|
74
|
+
}
|
|
64
75
|
const pdfAuthors = typeof document.info?.author === 'string'
|
|
65
76
|
? document.info.author.split(/[;,]/).map((entry) => entry.trim()).filter(Boolean)
|
|
66
77
|
: []
|
|
@@ -74,7 +85,7 @@ export async function loadPaper(source, options = {}) {
|
|
|
74
85
|
venue: cleanInline(htmlMeta.venue ?? document.venue ?? ''),
|
|
75
86
|
year: htmlMeta.year ?? document.year ?? guessYear(text),
|
|
76
87
|
doi: doi ?? '',
|
|
77
|
-
abstract: '',
|
|
88
|
+
abstract: cleanInline(htmlMeta.abstract ?? '').slice(0, 6000),
|
|
78
89
|
type: document.kind,
|
|
79
90
|
url: document.finalUrl ?? target.url ?? '',
|
|
80
91
|
}
|
|
@@ -121,6 +132,13 @@ export async function loadPaper(source, options = {}) {
|
|
|
121
132
|
}
|
|
122
133
|
}
|
|
123
134
|
|
|
135
|
+
// 出版社页面被反爬、只补到摘要时,用摘要当正文,至少能完成摘要级速读。
|
|
136
|
+
if (text === '' && meta.abstract.length > 100) {
|
|
137
|
+
text = meta.abstract
|
|
138
|
+
warnings.push('只拿到摘要文本,没有正文。')
|
|
139
|
+
}
|
|
140
|
+
if (text === '') warnings.push('没有拿到正文文字:可能只有元数据、需要登录,或页面被反爬拦截。')
|
|
141
|
+
|
|
124
142
|
const sections = parseSections(text)
|
|
125
143
|
// 本地抽出的摘要通常比 Crossref 的 JATS 摘要干净;优先用本地的。
|
|
126
144
|
const localAbstract = extractAbstract(text)
|
|
@@ -128,11 +146,17 @@ export async function loadPaper(source, options = {}) {
|
|
|
128
146
|
|| ''
|
|
129
147
|
if (localAbstract.length >= 150) meta.abstract = localAbstract
|
|
130
148
|
else if (meta.abstract === '' || meta.abstract === undefined) meta.abstract = localAbstract
|
|
131
|
-
if (sections.length === 0 && text.trim() !== ''
|
|
149
|
+
if (sections.length === 0 && text.trim() !== '' && text.length >= 4000) {
|
|
150
|
+
warnings.push('没有识别出章节标题,正文按整段返回。')
|
|
151
|
+
}
|
|
132
152
|
|
|
133
153
|
const selected = sections.length === 0
|
|
134
154
|
? {
|
|
135
|
-
sections: [{
|
|
155
|
+
sections: [{
|
|
156
|
+
key: text.length < 4000 ? 'abstract' : 'other',
|
|
157
|
+
title: text.length < 4000 ? 'Abstract' : 'Full text',
|
|
158
|
+
text: text.slice(0, sectionBudget),
|
|
159
|
+
}],
|
|
136
160
|
text: text.slice(0, sectionBudget),
|
|
137
161
|
}
|
|
138
162
|
: selectSections(sections, sectionBudget)
|
|
@@ -191,6 +215,31 @@ function extractDoiFromUrl(url) {
|
|
|
191
215
|
return match === null ? undefined : match[1].replace(/[.,;]+$/, '')
|
|
192
216
|
}
|
|
193
217
|
|
|
218
|
+
/**
|
|
219
|
+
* ScienceDirect 的 URL 没有 DOI,只有 PII;用 Crossref 的 `alternative-id` 反查 DOI。
|
|
220
|
+
* @param {string} url 出版社链接。
|
|
221
|
+
* @param {string[]} warnings 警告收集器。
|
|
222
|
+
* @param {number} timeoutMs 超时。
|
|
223
|
+
* @returns {Promise<string|undefined>}
|
|
224
|
+
*/
|
|
225
|
+
async function doiFromPii(url, warnings, timeoutMs) {
|
|
226
|
+
const pii = /\/pii\/([A-Z0-9]+)/i.exec(url)?.[1]
|
|
227
|
+
if (pii === undefined) return undefined
|
|
228
|
+
try {
|
|
229
|
+
const response = await fetchWithTimeout(
|
|
230
|
+
`https://api.crossref.org/works?filter=alternative-id:${encodeURIComponent(pii)}&rows=1&select=DOI`,
|
|
231
|
+
timeoutMs,
|
|
232
|
+
)
|
|
233
|
+
if (!response.ok) return undefined
|
|
234
|
+
const payload = await response.json()
|
|
235
|
+
const doi = payload?.message?.items?.[0]?.DOI
|
|
236
|
+
return typeof doi === 'string' && doi !== '' ? doi : undefined
|
|
237
|
+
} catch (error) {
|
|
238
|
+
warnings.push(`PII→DOI 查询失败:${messageOf(error)}`)
|
|
239
|
+
return undefined
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
194
243
|
/** 本地文件:PDF 或纯文本。 */
|
|
195
244
|
async function loadLocalFile(path, warnings, maxChars) {
|
|
196
245
|
const bytes = await readFile(path)
|
|
@@ -561,6 +610,30 @@ async function enrichByDoi(doi, warnings, timeoutMs) {
|
|
|
561
610
|
warnings.push(`Crossref 查询失败:${messageOf(error)}`)
|
|
562
611
|
}
|
|
563
612
|
|
|
613
|
+
// Semantic Scholar 通常有摘要,能补上 Elsevier 等不向 Crossref 存摘要的期刊。
|
|
614
|
+
try {
|
|
615
|
+
const response = await fetchWithTimeout(
|
|
616
|
+
`https://api.semanticscholar.org/graph/v1/paper/DOI:${doi}?fields=title,abstract,authors,year,venue,openAccessPdf`,
|
|
617
|
+
timeoutMs,
|
|
618
|
+
)
|
|
619
|
+
if (response.ok) {
|
|
620
|
+
const paper = await response.json()
|
|
621
|
+
if (result.title === '' && typeof paper?.title === 'string') result.title = paper.title
|
|
622
|
+
if (result.authors.length === 0 && Array.isArray(paper?.authors)) {
|
|
623
|
+
result.authors = paper.authors.map((author) => author?.name).filter(Boolean)
|
|
624
|
+
}
|
|
625
|
+
if (typeof paper?.abstract === 'string' && paper.abstract.trim() !== '') {
|
|
626
|
+
result.abstract = paper.abstract.replace(/^Abstract\s*/i, '').trim()
|
|
627
|
+
}
|
|
628
|
+
if (result.year === '' && paper?.year) result.year = String(paper.year)
|
|
629
|
+
const pdf = paper?.openAccessPdf?.url
|
|
630
|
+
if (typeof pdf === 'string' && pdf !== '' && result.pdfUrl === undefined) result.pdfUrl = pdf
|
|
631
|
+
found = found || result.title !== '' || result.abstract !== ''
|
|
632
|
+
}
|
|
633
|
+
} catch (error) {
|
|
634
|
+
warnings.push(`Semantic Scholar 查询失败:${messageOf(error)}`)
|
|
635
|
+
}
|
|
636
|
+
|
|
564
637
|
try {
|
|
565
638
|
const response = await fetchWithTimeout(`https://api.openalex.org/works/doi:${encodeURIComponent(doi)}`, timeoutMs)
|
|
566
639
|
if (response.ok) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sci-paper-digest",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Read an SCI journal or conference paper from a PDF, DOI, or URL and produce a bilingual (Chinese–English) method–object–finding digest with publication-grade English and reusable SCI sentence patterns.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
package/skill/SKILL.md
CHANGED
|
@@ -20,9 +20,17 @@
|
|
|
20
20
|
### 论文档案 | Paper record
|
|
21
21
|
一行写清:题目、作者(前 3 + et al.)、期刊/会议 + 年份、DOI、阅读范围(全文/仅摘要)。
|
|
22
22
|
|
|
23
|
-
### 0.
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
### 0. 双语速览段 | Bilingual summary(必须有,格式对齐)
|
|
24
|
+
先写一句中文点出研究核心/切入点(例如“跳出了……的常规思路,系统比较了……”),然后:
|
|
25
|
+
|
|
26
|
+
**中文:** 3–5 句,按“方法 → 对象/对比条件 → 结果 → 边界条件”组织;一段连续文字,不要 bullet。
|
|
27
|
+
|
|
28
|
+
**English:** 3–5 句,与中文信息量一致;方法过去时、结果过去时、结论现在时;缩写首次出现给全称;不添加原文没有的数字。
|
|
29
|
+
|
|
30
|
+
要求:
|
|
31
|
+
- 这一段要能独立读懂:不看后文也知道“做了什么、怎么做的、得到什么”。
|
|
32
|
+
- 中文与英文逐句对应,信息量一致;英文按 SCI 表达重组,不是逐字翻译。
|
|
33
|
+
- 不写“本文”“该研究”开头的空话,直接进入方法、对象和结果。
|
|
26
34
|
|
|
27
35
|
### 1. 方法 | Methods(3–5 条)
|
|
28
36
|
每条一行:
|
|
@@ -118,23 +126,27 @@
|
|
|
118
126
|
4. 表达提炼至少 6 条,模板可直接套用,不空泛。
|
|
119
127
|
5. 明确阅读范围;摘要级阅读不得给全文级结论。
|
|
120
128
|
|
|
121
|
-
##
|
|
129
|
+
## 六、示例(格式对齐;引用时核对原文)
|
|
130
|
+
|
|
131
|
+
**双语速览**
|
|
132
|
+
|
|
133
|
+
Tang 等(2021)跳出了“挡板等高”的常规思路,系统比较了不等高度分配方案(UBH)与常规等高方案(EBH)在 3D LNG 储罐中的抑晃表现。
|
|
134
|
+
|
|
135
|
+
**中文:** Tang 等采用 STAR-CCM+ 数值模拟研究了 3D LNG 储罐中不等挡板高度(UBH)分配方案对液体晃荡的抑制效果,在总挡板高度相同的条件下与等高度(EBH)方案进行对比。结果表明,挡板高度分配方式对晃荡控制存在影响;在不考虑挡板强度的前提下,具有适当高度梯度的 UBH 方案抑晃性能优于 EBH 方案。
|
|
122
136
|
|
|
123
|
-
|
|
124
|
-
- 中文:用三维 URANS 扫描 0–12% 开孔率,发现 8% 时首阶晃荡压力较无隔板下降 23.6%。
|
|
125
|
-
- English: Three-dimensional URANS simulations across opening ratios of 0–12% showed that an 8% opening reduced the first-order sloshing pressure by 23.6% relative to the unbaffled tank.
|
|
137
|
+
**English:** Tang et al. numerically investigated the suppression effects of unequal baffle height (UBH) allocation schemes on liquid sloshing in 3D LNG tanks using STAR-CCM+, and compared their performance with the equal baffle height (EBH) scheme under the condition of identical total baffle height. The results show that the baffle height allocation affects sloshing control, and that the UBH scheme with a proper baffle height gradient outperforms the EBH scheme when baffle strength is not taken into account.
|
|
126
138
|
|
|
127
|
-
**结果 1
|
|
128
|
-
- 方法 | Method
|
|
129
|
-
- 研究对象 | Object
|
|
130
|
-
- 研究结果 | Finding
|
|
131
|
-
- **SCI English**:
|
|
139
|
+
**结果 1|UBH 与 EBH 的抑晃对比**
|
|
140
|
+
- 方法 | Method:STAR-CCM+ 三维数值模拟,对比 UBH 与 EBH,设置不同挡板高度梯度
|
|
141
|
+
- 研究对象 | Object:3D LNG 储罐,总挡板高度相同,不同挡板数量/充液率/激励频率
|
|
142
|
+
- 研究结果 | Finding:挡板高度分配影响晃荡控制;适当高度梯度的 UBH 优于 EBH(不计挡板强度)
|
|
143
|
+
- **SCI English**: With the total baffle height held constant, the UBH scheme with a proper height gradient attenuated sloshing more effectively than the EBH scheme when baffle strength was not considered.
|
|
132
144
|
|
|
133
145
|
**表达提炼(节选)**
|
|
134
146
|
|
|
135
147
|
| 功能 | 可复用模板(英文) | 本文对应句/来源 |
|
|
136
148
|
|---|---|---|
|
|
137
|
-
|
|
|
149
|
+
| 报告对比结果 | Compared with [baseline], [method] reduced [metric] under [condition], whereas [alternative] showed [result]. | 据结果段改写 |
|
|
138
150
|
| 解释机理 | The observed [trend] is consistent with [mechanism], although [alternative] cannot be excluded. | 据讨论段改写 |
|
|
139
151
|
|
|
140
152
|
---
|