wwdeqiyi:计量文献自动分析 思维导图

时间:2026-07-25 16:21:01 来源:互联网

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, and text (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:

  1. Build a Python dict with the same nodes and edges structure as the template
  2. Use u201c and u201d Unicode escapes for ALL Chinese curly double-quotes within text values
  3. Use Python's json.dump with ensure_ascii=False and indent='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.dump correctly serializes n as the two-character escape sequence n, 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 n as 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.