From 99450966fe633307035df1c9c72c1979c2e4beb0 Mon Sep 17 00:00:00 2001 From: YeLongYi <9237352+yelongyi@user.noreply.gitee.com> Date: Sat, 23 Sep 2023 08:14:21 +0000 Subject: [PATCH] =?UTF-8?q?paper-summary=E7=BE=8E=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: YeLongYi <9237352+yelongyi@user.noreply.gitee.com> --- paper-summary-beautify | 252 ++++++++++++++++++++++++++ paper-summary.yaml | 400 ++++++++++++++++++++++++++--------------- 2 files changed, 504 insertions(+), 148 deletions(-) create mode 100644 paper-summary-beautify diff --git a/paper-summary-beautify b/paper-summary-beautify new file mode 100644 index 0000000..8710b87 --- /dev/null +++ b/paper-summary-beautify @@ -0,0 +1,252 @@ +// @use-markdown +// @author Polygon +// @link https://gitee.com/zotero-chinese/zotero-magic-for-user/blob/master/paper-summary.yaml +// @warning 文献的基本结构包括: 1. introduction, 2. method,3. result, 4 discussion + + +

${topItem.getField('title')}

+
+

💡 Meta Data

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Title

+
+ ${topItem.getField('title')} +
+

${(()=>{ + if(topItem.itemType === "conferencePaper") return "Conference"; + if(topItem.itemType === "journalArticle") return "Journal"; + if(topItem.itemType === "report") return "Publisher"; + return "Publisher";})()}

+

${(()=>{ + if(topItem.itemType === "conferencePaper") { + const res = topItem.getField("conferenceName"); + return res?res:topItem.getField("proceedingsTitle"); + }; + if(topItem.itemType === "journalArticle") return topItem.getField("publicationTitle"); + if(topItem.itemType === "report") return topItem.getField("institution"); + return topItem.getField("publicationTitle");})()}

+
+

Authors

+
+ ${topItem.getCreators().map((v)=>v.firstName+" "+v.lastName).join("; ")} +
+

Pub. date

+
+ ${topItem.getField('date')} +
+

期刊标签

+
+ ${(() => { + let tags = Zotero.ZoteroStyle.data.ztoolkit.ItemTree.fieldHooks.globalCache.getFieldHooks.PublicationTags( + "", true, true, topItem, undefined); + let out = ""; + if (!tags){ + out += ``; + }else{ + const jsonStartIndex = tags.indexOf('{'); + if (jsonStartIndex !== -1) { + tags = tags.slice(jsonStartIndex); + } + let regex = /"(sci|sciif)":"([^"]+)"/g; + let matches = tags.match(regex); + + const keyValuePairs = JSON.parse(tags); + const colors = ["#ff6666", "#ffd400", "#5fb236", "#2ea8e5", "#a28ae5"]; + + + for (const key in keyValuePairs) { + if (key === "sci") { + out += `SCI ${keyValuePairs[key]}`; + } + if (key === "sciUp") { + out += `中科院 ${keyValuePairs[key]}`; + } + if (key === "sciif") { + out += `IF ${keyValuePairs[key]}`; + } + if (key === "pku") { + out += ` 北核`; + } + if (key === "cssci") { + out += ` ${keyValuePairs[key]}`; + } + } + } + return out; + })()} +
+

DOI

+
+ ${topItem.getField('DOI')} +
+

附件

+
+ + ${Zotero.Items.get(topItem.getAttachments())[0].getFilename()} + +
+ +${{ +// ✍️可修改[0]为[1] +sharedObj.by = ["Magic", "Grobid"][0] +// ✍️可修改"简体中文"为"其它语言" +sharedObj.language = "简体中文" +sharedObj.itemID = (await targetNoteItem.parentItem.getBestAttachment()).id; +sharedObj.setGPTText = async (text) => { + const window = Zotero.getMainWindow() + await window.Meet.Global.views.show() + window.Meet.Global.views.inputContainer.querySelector("input").value = text +} +sharedObj.getBasicInfo = async () => { + return await Zotero.ZoteroMagic.api.paperSummary.getBasicInfo(sharedObj.by, sharedObj.itemID) +} +sharedObj.getSectionInfo = async (keywords) => { + return await Zotero.ZoteroMagic.api.paperSummary.getSectionInfo(keywords, sharedObj.by, sharedObj.itemID) +} +sharedObj.setGPTSystemMsg = () => { + const window = Zotero.getMainWindow() + window.Meet.Global.views.messages = [ + { + "role": "system", + // ✍️可修改[气溶胶遥感、气溶胶反演]为[你的专业领域关键词1、你的专业领域关键词2] + "content": "You are ChatGPT, a large language model trained by OpenAI.\nKnowledge cutoff: 2021-09 \nCurrent date: [2023-09-15]" + } + ] +} +sharedObj.getGPTResponseText = async (question) => { + const window = Zotero.getMainWindow() + return await window.Meet.Global.views.execText(question) +} +return " " +}}$ + +

📜 研究背景 & 基础 & 目的

+
+

+ + +${{ +await sharedObj.setGPTText("GPT正在总结[背景]...") +// ✍️可修改["intro"]为["有关背景的副标题1", "有关背景的副标题2"] +const sectionInfo = await sharedObj.getSectionInfo(["intro"]) +const text = JSON.stringify(sectionInfo); +// ✍️可修改以下内容 +return await sharedObj.getGPTResponseText(` + This is the part of an English literature, I need your help to summarize the following questions: + ${text} + + --- + + 按照如下格式概括,小标题单独一行,格式为Markdown格式的三级标题: + ### 研究背景 + (What is the research background of this article?) + ### 过去方案 + (What are the past methods? What are the problems with them? Is the approach well motivated?) + ### 研究动机 + (为什么要开展本研究) + + 请用 ${sharedObj.language} 作答(专业词汇仍使用英语), statements as concise and academic as possible, 请不要将括号内要求输出。 +`) +}}$ + +

📊 研究内容

+
+

+ +${{ +await sharedObj.setGPTText("GPT正在总结[方法]...") +// ✍️可修改["method"]为["有关方法的副标题1", "有关方法的副标题2"] +const sectionInfo = await sharedObj.getSectionInfo(["method"]) +const text = JSON.stringify(sectionInfo); +// ✍️可修改以下内容 +return await sharedObj.getGPTResponseText(` + This is the part of an English document, I need your help to read and summarize the following questions. + ${text} + + --- + Describe in detail the methodological idea of this article. 按照如下格式输出: + ### 理论背景 + (这里概述本研究的理论基础) + ### 技术路线 + (这里概述本研究的实现过程) + + 请用 ${sharedObj.language} 作答(专业词汇仍使用英语), statements as concise and academic as possible, 请不要将括号内要求输出。 +`) +}}$ + +

🚩 研究结论

+
+

+ +${{ +await sharedObj.setGPTText("GPT正在总结[结论]...") +// ✍️可修改["conclu", "result", "disscuss"]为["有关结论的副标题1", "有关结论的副标题2"] +const sectionInfo = await sharedObj.getSectionInfo(["conclu", "result", "disscuss"]) +const text = JSON.stringify(sectionInfo); +// ✍️可修改以下内容 +return await sharedObj.getGPTResponseText(` + This is the part of an English literature, I need your help to summarize the following questions: + ${text} + + --- + 按照下面格式输出: + ### 研究意义 + - (此处概述本文的研究意义) + ### 优缺点 + - (此处总结研究的优缺点,未提及则不用回答) + ### 主要结论 + (此处依次罗列文章的主要结论,如果没有不用回答) + (1)xxx; + (2)xxx; + ... + + 请用 ${sharedObj.language} 作答(专业词汇仍使用英语), statements as concise and academic as possible, 请不要将括号内要求输出。 +`) +}}$ + +

🔬 创新点

+
+

+ + +

📌 感想 & 疑问

+
+

+ + + +${{ +const window = Zotero.getMainWindow() +window.Meet.Global.views.hide() +return "" +}}$ \ No newline at end of file diff --git a/paper-summary.yaml b/paper-summary.yaml index f8bc8d3..7fbbd78 100644 --- a/paper-summary.yaml +++ b/paper-summary.yaml @@ -1,148 +1,252 @@ -# This template is specifically for importing/sharing, using better -# notes 'import from clipboard': copy the content and -# goto Zotero menu bar, click Edit->New Template from Clipboard. -# Do not copy-paste this to better notes template editor directly. -name: "[text] Paper Summary" -content: |- - // @use-markdown - // @author Polygon - // @link https://gitee.com/zotero-chinese/zotero-magic-for-user/blob/master/paper-summary.yaml - // @warning 文献的基本结构包括: 1. introduction, 2. method,3. result, 4 discussion - ${{ - // ✍️可修改[0]为[1] - sharedObj.by = ["Magic", "Grobid"][0] - // ✍️可修改"简体中文"为"其它语言" - sharedObj.language = "简体中文" - sharedObj.itemID = (await targetNoteItem.parentItem.getBestAttachment()).id; - sharedObj.setGPTText = async (text) => { - const window = Zotero.getMainWindow() - await window.Meet.Global.views.show() - window.Meet.Global.views.inputContainer.querySelector("input").value = text - } - sharedObj.getBasicInfo = async () => { - return await Zotero.ZoteroMagic.api.paperSummary.getBasicInfo(sharedObj.by, sharedObj.itemID) - } - sharedObj.getSectionInfo = async (keywords) => { - return await Zotero.ZoteroMagic.api.paperSummary.getSectionInfo(keywords, sharedObj.by, sharedObj.itemID) - } - sharedObj.setGPTSystemMsg = () => { - const window = Zotero.getMainWindow() - window.Meet.Global.views.messages = [ - { - "role": "system", - // ✍️可修改[气溶胶遥感、气溶胶反演]为[你的专业领域关键词1、你的专业领域关键词2] - "content": "You are a researcher in the field of [气溶胶遥感、气溶胶反演] who is good at summarizing papers using concise statements" - } - ] - } - sharedObj.getGPTResponseText = async (question) => { - if (_env.dryRun) {return "GPT回答内容"} - const window = Zotero.getMainWindow() - return await window.Meet.Global.views.execText(question) - } - return "# " + targetNoteItem.parentItem.getField("title") - }}$ - - # 基本信息 - ${{ - await sharedObj.setGPTText("GPT正在总结[基本信息]...") - const basicInfo = await sharedObj.getBasicInfo(); - const text = JSON.stringify(basicInfo); - sharedObj.setGPTSystemMsg() - // ✍️可修改以下内容 - return await sharedObj.getGPTResponseText(` - This is the title, author, link, abstract and introduction of an English document. I need your help to read and summarize the following questions: - ${text} - - --- - - 标题: (这里填充本文标题,翻译成中文后的) - - 作者: (填充本文第一作者,英文形式) - - 机构: (填写第一作者所属单位,英文+中文) - - 关键词: (填写本文关键词,英文形式) - ## 摘要概述 - (这里务必空两行) - --- - ( - 简要概述本文摘要填充下列markdown表格,如未提及请用"-"表示,markdown格式输出,这句话不要输出,仅仅输出表格 - - |项目|内容| - |--|--| - |📖研究背景|| - |🎯研究目的|| - |✍️研究方法|| - |🕊️研究对象|| - |🔍研究结论|| - |⭐创新点|| - ) - 请用 ${sharedObj.language} 作答(专业词汇仍使用英语), statements as concise and academic as possible, 请不要将括号内要求输出。输出内容根据\n换行,严格按照上述格式输出。 - `) - }}$ - - # 背景 - ${{ - await sharedObj.setGPTText("GPT正在总结[背景]...") - // ✍️可修改["intro"]为["有关背景的副标题1", "有关背景的副标题2"] - const sectionInfo = await sharedObj.getSectionInfo(["intro"]) - const text = JSON.stringify(sectionInfo); - // ✍️可修改以下内容 - return await sharedObj.getGPTResponseText(` - This is the part of an English literature, I need your help to summarize the following questions: - ${text} - - --- - - 按照如下格式概括: - - 研究背景: (What is the research background of this article?) - - 过去方案: (What are the past methods? What are the problems with them? Is the approach well motivated?) - - 研究动机: (为什么要开展本研究) - - 请用 ${sharedObj.language} 作答(专业词汇仍使用英语), statements as concise and academic as possible, 请不要将括号内要求输出。 - `) - }}$ - - # 方法 - ${{ - await sharedObj.setGPTText("GPT正在总结[方法]...") - // ✍️可修改["method"]为["有关方法的副标题1", "有关方法的副标题2"] - const sectionInfo = await sharedObj.getSectionInfo(["method"]) - const text = JSON.stringify(sectionInfo); - // ✍️可修改以下内容 - return await sharedObj.getGPTResponseText(` - This is the part of an English document, I need your help to read and summarize the following questions. - ${text} - - --- - Describe in detail the methodological idea of this article. 按照如下格式输出: - - 理论背景: (这里概述本研究的理论基础) - - 技术路线: (这里概述本研究的实现过程) - - 请用 ${sharedObj.language} 作答(专业词汇仍使用英语), statements as concise and academic as possible, 请不要将括号内要求输出。 - `) - }}$ - - # 结论 - ${{ - await sharedObj.setGPTText("GPT正在总结[结论]...") - // ✍️可修改["conclu", "result", "disscuss"]为["有关结论的副标题1", "有关结论的副标题2"] - const sectionInfo = await sharedObj.getSectionInfo(["conclu", "result", "disscuss"]) - const text = JSON.stringify(sectionInfo); - // ✍️可修改以下内容 - return await sharedObj.getGPTResponseText(` - This is the part of an English literature, I need your help to summarize the following questions: - ${text} - - --- - 按照下面格式输出: - - (此处概述本文的研究意义) - - (此处总结研究的优缺点,未提及则不用回答) - - 主要结论: (1)xxx; (2)xxx; ... (此处依次罗列文章的主要结论,如果没有不用回答) - - 请用 ${sharedObj.language} 作答(专业词汇仍使用英语), statements as concise and academic as possible, 请不要将括号内要求输出。 - `) - }}$ - - ${{ - const window = Zotero.getMainWindow() - window.Meet.Global.views.hide() - return "" - }}$ +// @use-markdown +// @author Polygon +// @link https://gitee.com/zotero-chinese/zotero-magic-for-user/blob/master/paper-summary.yaml +// @warning 文献的基本结构包括: 1. introduction, 2. method,3. result, 4 discussion + + +

${topItem.getField('title')}

+
+

💡 Meta Data

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Title

+
+ ${topItem.getField('title')} +
+

${(()=>{ + if(topItem.itemType === "conferencePaper") return "Conference"; + if(topItem.itemType === "journalArticle") return "Journal"; + if(topItem.itemType === "report") return "Publisher"; + return "Publisher";})()}

+

${(()=>{ + if(topItem.itemType === "conferencePaper") { + const res = topItem.getField("conferenceName"); + return res?res:topItem.getField("proceedingsTitle"); + }; + if(topItem.itemType === "journalArticle") return topItem.getField("publicationTitle"); + if(topItem.itemType === "report") return topItem.getField("institution"); + return topItem.getField("publicationTitle");})()}

+
+

Authors

+
+ ${topItem.getCreators().map((v)=>v.firstName+" "+v.lastName).join("; ")} +
+

Pub. date

+
+ ${topItem.getField('date')} +
+

期刊标签

+
+ ${(() => { + let tags = Zotero.ZoteroStyle.data.ztoolkit.ItemTree.fieldHooks.globalCache.getFieldHooks.PublicationTags( + "", true, true, topItem, undefined); + let out = ""; + if (!tags){ + out += ``; + }else{ + const jsonStartIndex = tags.indexOf('{'); + if (jsonStartIndex !== -1) { + tags = tags.slice(jsonStartIndex); + } + let regex = /"(sci|sciif)":"([^"]+)"/g; + let matches = tags.match(regex); + + const keyValuePairs = JSON.parse(tags); + const colors = ["#ff6666", "#ffd400", "#5fb236", "#2ea8e5", "#a28ae5"]; + + + for (const key in keyValuePairs) { + if (key === "sci") { + out += `SCI ${keyValuePairs[key]}`; + } + if (key === "sciUp") { + out += `中科院 ${keyValuePairs[key]}`; + } + if (key === "sciif") { + out += `IF ${keyValuePairs[key]}`; + } + if (key === "pku") { + out += ` 北核`; + } + if (key === "cssci") { + out += ` ${keyValuePairs[key]}`; + } + } + } + return out; + })()} +
+

DOI

+
+ ${topItem.getField('DOI')} +
+

附件

+
+ + ${Zotero.Items.get(topItem.getAttachments())[0].getFilename()} + +
+ +${{ +// ✍️可修改[0]为[1] +sharedObj.by = ["Magic", "Grobid"][0] +// ✍️可修改"简体中文"为"其它语言" +sharedObj.language = "简体中文" +sharedObj.itemID = (await targetNoteItem.parentItem.getBestAttachment()).id; +sharedObj.setGPTText = async (text) => { + const window = Zotero.getMainWindow() + await window.Meet.Global.views.show() + window.Meet.Global.views.inputContainer.querySelector("input").value = text +} +sharedObj.getBasicInfo = async () => { + return await Zotero.ZoteroMagic.api.paperSummary.getBasicInfo(sharedObj.by, sharedObj.itemID) +} +sharedObj.getSectionInfo = async (keywords) => { + return await Zotero.ZoteroMagic.api.paperSummary.getSectionInfo(keywords, sharedObj.by, sharedObj.itemID) +} +sharedObj.setGPTSystemMsg = () => { + const window = Zotero.getMainWindow() + window.Meet.Global.views.messages = [ + { + "role": "system", + // ✍️可修改[气溶胶遥感、气溶胶反演]为[你的专业领域关键词1、你的专业领域关键词2] + "content": "You are ChatGPT, a large language model trained by OpenAI.\nKnowledge cutoff: 2021-09 \nCurrent date: [2023-09-15]" + } + ] +} +sharedObj.getGPTResponseText = async (question) => { + const window = Zotero.getMainWindow() + return await window.Meet.Global.views.execText(question) +} +return "" +}}$ + +

📜 研究背景 & 基础 & 目的

+
+

+ + +${{ +await sharedObj.setGPTText("GPT正在总结[背景]...") +// ✍️可修改["intro"]为["有关背景的副标题1", "有关背景的副标题2"] +const sectionInfo = await sharedObj.getSectionInfo(["intro"]) +const text = JSON.stringify(sectionInfo); +// ✍️可修改以下内容 +return await sharedObj.getGPTResponseText(` + This is the part of an English literature, I need your help to summarize the following questions: + ${text} + + --- + + 按照如下格式概括,小标题单独一行,格式为Markdown格式的二级标题: + ## 研究背景 + (What is the research background of this article?) + ## 过去方案 + (What are the past methods? What are the problems with them? Is the approach well motivated?) + ## 研究动机 + (为什么要开展本研究) + + 请用 ${sharedObj.language} 作答(专业词汇仍使用英语), statements as concise and academic as possible, 请不要将括号内要求输出。 +`) +}}$ + +

📊 研究内容

+
+

+ +${{ +await sharedObj.setGPTText("GPT正在总结[方法]...") +// ✍️可修改["method"]为["有关方法的副标题1", "有关方法的副标题2"] +const sectionInfo = await sharedObj.getSectionInfo(["method"]) +const text = JSON.stringify(sectionInfo); +// ✍️可修改以下内容 +return await sharedObj.getGPTResponseText(` + This is the part of an English document, I need your help to read and summarize the following questions. + ${text} + + --- + Describe in detail the methodological idea of this article. 按照如下格式输出: + ## 理论背景 + (这里概述本研究的理论基础) + ## 技术路线 + (这里概述本研究的实现过程) + + 请用 ${sharedObj.language} 作答(专业词汇仍使用英语), statements as concise and academic as possible, 请不要将括号内要求输出。 +`) +}}$ + +

🚩 研究结论

+
+

+ +${{ +await sharedObj.setGPTText("GPT正在总结[结论]...") +// ✍️可修改["conclu", "result", "disscuss"]为["有关结论的副标题1", "有关结论的副标题2"] +const sectionInfo = await sharedObj.getSectionInfo(["conclu", "result", "disscuss"]) +const text = JSON.stringify(sectionInfo); +// ✍️可修改以下内容 +return await sharedObj.getGPTResponseText(` + This is the part of an English literature, I need your help to summarize the following questions: + ${text} + + --- + 按照下面格式输出: + ## 研究意义 + - (此处概述本文的研究意义) + ## 优缺点 + - (此处总结研究的优缺点,未提及则不用回答) + ## 主要结论 + (此处依次罗列文章的主要结论,如果没有不用回答) + (1)xxx; + (2)xxx; + ... + + 请用 ${sharedObj.language} 作答(专业词汇仍使用英语), statements as concise and academic as possible, 请不要将括号内要求输出。 +`) +}}$ + +

🔬 创新点

+
+

+ + +

📌 感想 & 疑问

+
+

+ + + +${{ +const window = Zotero.getMainWindow() +window.Meet.Global.views.hide() +return "" +}}$ \ No newline at end of file -- Gitee