wwdeqiyi:计量文献自动分析 思维导图
PDF to Obsidian Canvas — Academic Paper Analysis
Overview
Analyze an academic paper PDF against a predefined canvas template (计量文献分析框架.canvas) and produce an
Obsidian-compatible .canvas file. The template defines a node-edge graph structure covering bibliographic
info, abstract, introduction, literature review, hypotheses, data, methods, results, and contributions.
Workflow
Step 1: Read the Template Canvas
Read the canvas template file (user-provided path, typically 计量文献分析框架.canvas). Parse its JSON to
extract:
- Every node's
id,x,y,width,height, andtext(the latter carries the content placeholder/instruction) - Every edge's
id,fromNode,fromSide,toNode,toSide
The template's text fields contain instructions in Chinese with a PS marker indicating what to fill.
Replace each placeholder with the actual analysis content. Section-header nodes (e.g. "文献信息",
"结构化信息", "数据", "结果") keep their short labels.
Step 2: Extract Text from the PDF
Use PyPDF2 to extract all text from the paper PDF. If PyPDF2 is unavailable, install it into the managed Python environment first. Read pages sequentially and concatenate all text for analysis.
Step 3: Analyze the Paper — Fill Each Template Node
Map each template node to the corresponding analysis. The major node groups and their content expectations:
| Node Group | Key Content to Fill |
|---|---|
| 文献名称 | Full APA citation |
| 期刊 | Journal name, ABS/FT50/UTD24 tier |
| 主题 | Research domain/field (1 line) |
| 一句话总结 | ≤30 Chinese characters on core contribution |
| 标签 | English + Chinese hashtags |
| 摘要 | Original English abstract |
| 中文译文 | Full Chinese translation of abstract |
| 引言 | How the paper enters the field, research questions, research design |
| 引言逻辑结构 | Numbered steps of the introduction's argument flow |
| 研究问题 | Explicit RQs |
| 研究空白 | Numbered list of research gaps |
| 研究设计 | Data source, methods, analysis plan |
| 文献综述 | What theories are used, what each LR section covers |
| 涉及理论 | Named theories with key citations |
| 理论构建框架 | The conceptual framework the paper builds |
| 研究假设 | All hypotheses with derivation logic |
| 数据采集 | Data source, collection method, time range, sample size |
| 变量 | DV, IV, controls, moderators with measurement |
| 模型 | Econometric model specification with formulas |
| 结果分析 | Which hypotheses are supported/not, key coefficients |
| 稳健性检验 | Each robustness check and its rationale |
| 理论贡献 | Numbered theoretical contributions |
Step 4: Generate the Canvas JSON
CRITICAL — use scripts/canvas_builder.py to produce the final file. Do NOT write JSON directly with
the Write tool. The script ensures proper formatting that Obsidian can parse.
The script approach:
- Build a Python dict with the same
nodesandedgesstructure as the template - Use
u201candu201dUnicode escapes for ALL Chinese curly double-quotes within text values - Use Python's
json.dumpwithensure_ascii=Falseandindent='t'to serialize
Why the script is mandatory:
- Writing JSON directly with the Write tool causes Chinese curly quotes (
"", U+201C/U+201D) to be flattened to ASCII straight quotes (", U+0022), which breaks JSON parsing because the straight quotes are interpreted as JSON string delimiters - Python's
json.dumpcorrectly serializesnas the two-character escape sequencen, which Obsidian Canvas requires for multi-line text nodes - Tab indentation (
indent='t') matches the template's formatting
Usage of the builder script:
python scripts/canvas_builder.py --template template.canvas --output output.canvas
However, in most cases it is cleaner to write a custom Python script inline that constructs
the node content dict and calls json.dump, because each paper's analysis content is unique.
The key invariant is: always use json.dump, never Write tool for canvas JSON.
Step 5: Validate and Deliver
After writing the canvas file, verify:
- JSON is valid (the script ensures this)
- Node count matches the template
- Edge count matches the template
- Multi-line text nodes show
nas literal backslash-n, not actual newlines
Present the file with present_files. Clean up temporary scripts.
Chinese Quotation Mark Handling — Mandatory Rule
For ALL text content that contains Chinese curly double-quotes, use Python variables:
LQ = "u201c" # Chinese left double quote "
RQ = "u201d" # Chinese right double quote "
text = "文章提出" + LQ + "核心概念" + RQ + "的定义"
Never embed the raw " / " characters directly in Python string literals — use the Unicode
escape variables above. This prevents any risk of the quotes being flattened to ASCII.
Template Preservation
Preserve the template's node id, x, y, width, height values exactly. Only modify text
and (optionally, if content overflows) width/height for content nodes.
Preserve all edge definitions exactly as-is — they encode the visual graph topology.