sci-paper-digest 1.0.0 → 1.0.2

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 CHANGED
@@ -28,11 +28,12 @@
28
28
  默认“3 分钟速读版”:
29
29
 
30
30
  1. 论文档案(题目、作者、期刊/会议、年份、DOI、阅读范围)
31
- 2. 一句话速览(中/英)
32
- 3. 方法(3–5 条)
33
- 4. 主要结果:每条都有「方法 / 研究对象 / 研究结果 / SCI English」
34
- 5. **SCI 表达提炼**:6–8 条可复用句式模板,`[ ]` 占位,替换即可用
35
- 6. 创新点与局限
31
+ 2. **一句话总括(五要素)**:研究对象 + 外激励条件 + 方法(实验+数值模拟)+ 关键结果 + 机理解释,中英各一句
32
+ 3. **双语速览段**:**中文:** 3–5 句 + **English:** 3–5 句
33
+ 4. 方法(3–5 条)
34
+ 5. 主要结果:每条都有「方法 / 研究对象 / 研究结果 / SCI English」
35
+ 6. **SCI 表达提炼**:6–8 条可复用句式模板,`[ ]` 占位,替换即可用
36
+ 7. 创新点与局限
36
37
 
37
38
  说“精读 / 详细 / 逐段 / 审稿”时再展开深读版:研究缺口、逐节要点、证据强度、可引用英文句、术语表。
38
39
 
package/docs/DETAIL.md CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  上传一篇 SCI 期刊/会议论文的 PDF,或粘贴论文链接 / DOI / arXiv 号,得到一份**中英对照**的速读摘要:
4
4
 
5
- - 一句话结论;
5
+ - **一句话总括(五要素)**:研究对象 + 外激励条件 + 方法(实验 + 数值模拟)+ 关键结果 + 机理解释,中英各一句;
6
+ - **双语速览段**:**中文:** 与 **English:** 各 3–5 句,补充工况、指标和边界;
6
7
  - 研究方法(3–5 条);
7
8
  - 每一个主要结果的「方法 — 研究对象 — 研究结果」三要素;
8
9
  - 对应的 **SCI 级英文表达**;
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.stats.chars > maxChars
51
- ? `正文约 ${paper.stats.chars} 字符,本次只放入 ${maxChars};summary 中不要假装读过未提供部分。`
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` 技能输出“速读版”:论文档案、一句话速览、方法(3–5 条)、逐条结果(方法—研究对象—结果 + SCI English)、6–8 条可复用 SCI 表达模板、创新点与局限。用户要精读时再展开深读版。',
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
- document = await loadUrl(target.url, warnings, timeoutMs)
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
- const doi = htmlMeta.doi ?? document.doi ?? findDoi(text)
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() !== '') warnings.push('没有识别出章节标题,正文按整段返回。')
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: [{ key: 'other', title: 'Full text', text: text.slice(0, sectionBudget) }],
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.0",
3
+ "version": "1.0.2",
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,24 @@
20
20
  ### 论文档案 | Paper record
21
21
  一行写清:题目、作者(前 3 + et al.)、期刊/会议 + 年份、DOI、阅读范围(全文/仅摘要)。
22
22
 
23
- ### 0. 一句话速览 | One-sentence takeaway
24
- - 中文:一句话说清“用什么方法、在什么对象上、得到什么可量化结论”。
25
- - English: one sentence with method + object + quantified finding.
23
+ ### 0. 一句话总括(五要素)+ 双语速览段
24
+
25
+ **第一句必须是“五要素一句话”**,顺序固定:
26
+
27
+ > 研究对象 + 外激励条件 + 方法(实验 + 数值模拟)+ 关键结果 + 机理解释
28
+
29
+ 中文模板:
30
+
31
+ > 针对【研究对象】在【外激励条件】下的【问题】,【作者】结合【实验方法】与【数值方法】研究了【关键变量/方案】,发现【关键结果】,并将其归因于【机理】。
32
+
33
+ English 模板:
34
+
35
+ > For [object] under [excitation], [experimental method] and [numerical simulation] were combined to investigate [variable]; [key result] was observed, which is attributed to [mechanism].
36
+
37
+ 规则:
38
+ - 五个要素缺一不可;论文没有实验就写“仅数值模拟”,没有明确机理就写“原文未明确说明”,不要编造。
39
+ - 这句话要能独立作为文献综述里的一行。
40
+ - 然后再展开 **中文:** 3–5 句和 **English:** 3–5 句;展开段补充工况、指标和边界,不要重复堆砌同一句。
26
41
 
27
42
  ### 1. 方法 | Methods(3–5 条)
28
43
  每条一行:
@@ -118,23 +133,29 @@
118
133
  4. 表达提炼至少 6 条,模板可直接套用,不空泛。
119
134
  5. 明确阅读范围;摘要级阅读不得给全文级结论。
120
135
 
121
- ## 六、示例(数值仅示意,禁止照抄)
136
+ ## 六、示例(格式对齐;引用时核对原文)
137
+
138
+ **一句话总括(五要素)**
139
+
140
+ 针对 3D LNG 储罐在不同激励频率下的晃荡控制问题,Tang 等以试验结果校验 k-ε 模型并采用 STAR-CCM+ 数值模拟,比较总高度相同的 EBH 与 UBH 方案,发现适当高度梯度的 UBH 抑晃更优,其机理在于挡板高度梯度改变了沿舱壁的波高与载荷分布(摘要未展开,需全文核实)。
141
+
142
+ **English one-sentence:** For sloshing control in a 3D LNG tank under different excitation frequencies, Tang et al. calibrated the k-ε model against experimental data and performed STAR-CCM+ simulations to compare EBH and UBH schemes with identical total baffle height; the UBH scheme with a proper height gradient suppressed sloshing more effectively, which is attributed to the height gradient redistributing wave height and wall loads along the tank (not elaborated in the abstract).
143
+
144
+ **中文:** Tang 等采用 STAR-CCM+ 数值模拟研究了 3D LNG 储罐中不等挡板高度(UBH)分配方案对液体晃荡的抑制效果,在总挡板高度相同的条件下与等高度(EBH)方案进行对比。结果表明,挡板高度分配方式对晃荡控制存在影响;在不考虑挡板强度的前提下,具有适当高度梯度的 UBH 方案抑晃性能优于 EBH 方案。
122
145
 
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.
146
+ **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
147
 
127
- **结果 1|开孔率对首阶压力的抑制**
128
- - 方法 | Method:三维 URANS + 浮力修正 k-ω SST,开孔率 0–12% 参数扫描
129
- - 研究对象 | Object:矩形液舱,充液率 50%,一阶共振工况
130
- - 研究结果 | Finding:8% 开孔率下首阶压力峰值下降 23.6%(p < 0.05),二阶峰上升 6.1%
131
- - **SCI English**: At an opening ratio of 8%, the first-order impact pressure on the tank wall was 23.6% lower than that of the unbaffled case (p < 0.05), whereas the second-order peak increased by 6.1%, indicating that the perforated baffle attenuates low-frequency sloshing loads more effectively than high-frequency components.
148
+ **结果 1|UBH 与 EBH 的抑晃对比**
149
+ - 方法 | Method:STAR-CCM+ 三维数值模拟,对比 UBH 与 EBH,设置不同挡板高度梯度
150
+ - 研究对象 | Object:3D LNG 储罐,总挡板高度相同,不同挡板数量/充液率/激励频率
151
+ - 研究结果 | Finding:挡板高度分配影响晃荡控制;适当高度梯度的 UBH 优于 EBH(不计挡板强度)
152
+ - **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
153
 
133
154
  **表达提炼(节选)**
134
155
 
135
156
  | 功能 | 可复用模板(英文) | 本文对应句/来源 |
136
157
  |---|---|---|
137
- | 报告提升/下降 | [Metric] decreased by [X]% (from [A] to [B]; p < [value], n = [N]) under [condition]. | 据结果段改写 |
158
+ | 报告对比结果 | Compared with [baseline], [method] reduced [metric] under [condition], whereas [alternative] showed [result]. | 据结果段改写 |
138
159
  | 解释机理 | The observed [trend] is consistent with [mechanism], although [alternative] cannot be excluded. | 据讨论段改写 |
139
160
 
140
161
  ---