Course Mindmap Generator
Overview
将高校课堂课件(PPT/Word)自动转化为结构化思维导图Word文档,文档采用标准 Heading 1~4标题样式,可直接导入XMind生成思维导图。涵盖文件验证、内容提取、 知识点层级分析、Word文档生成的完整工作流程。
Workflow
Step 1: File Validation
验证上传文件是否为合法课件格式。
Supported formats:
- PPT:
.pptx.ppt.ppsx.potx - Word:
.docx.doc.wps.wpt
Validation order (critical):
- File existence → if missing: report "文件不存在"
- Extension check → if not PPT/Word: report "请上传课件Word或PPT文件"
- Empty file check → if 0 bytes: report "文件无效:文件为空"
If user uploads an image (PNG/JPG/screenshot), do NOT attempt to recognize image content — directly respond: "请上传课件Word或PPT文件"
Step 2: Content Extraction
Extract text content from the courseware.
For PPT files — use scripts/mindmap_workflow.py or python-pptx directly:
- Copy file to temp path first (Chinese path encoding workaround on Windows)
- Validate file is valid zip (PPTX header starts with
PK) - Iterate slides, extract text from all shapes and tables
- Record font size for each paragraph (used for title detection)
- Filter noise: page numbers, headers/footers, author info, formula fragments
For Word files — use python-docx:
- Copy to temp path, extract all paragraph text
Chinese path handling: python-pptx and python-docx may fail on Chinese paths. Always copy the source file to a temp ASCII path before processing:
import shutil, os
tmp = os.path.join(os.environ.get('TEMP', '/tmp'), '_workflow_tmp' + ext)
shutil.copy2(src, tmp)
# process tmp, then remove
os.remove(tmp)
Step 3: Content Sufficiency Check
Verify the extracted content has enough material to generate a meaningful mindmap. Minimum threshold: 3 slides/paragraphs with non-empty text. If insufficient, report "文件无效:文档内容过少,无法提取有效知识点"
Step 4: Knowledge Structure Analysis
Analyze extracted content to build a hierarchical structure:
- Level 1 (Chapter):
第X章,§14.1patterns - Level 2 (Section):
一、,二、Chinese numbered headings - Level 3 (Knowledge Point):
1.,2.Arabic numbered items,【例X】 - Level 4 (Sub-point): detailed points under each knowledge point
See references/knowledge_structure_rules.md for the full regex patterns,
filtering rules, and font-size heuristics.
Important: Automatic rule-based extraction often produces fragmented results
for physics/math PPTs (formulas get split into pieces). For best quality,
use AI-enhanced mode: manually analyze the PPT content, construct a structured
JSON, then feed it to the workflow script via --ai parameter.
Step 5: Word Document Generation
Generate the mindmap Word document with proper heading styles for XMind import.
Heading style mapping:
- Heading 1 → Chapter (一级章节)
- Heading 2 → Section (二级小节)
- Heading 3 → Knowledge Point (三级知识点)
- Heading 4 → Sub-point (四级细分考点)
Document title and import instructions use Normal style (not imported by XMind).
Using the script:
# Auto-analysis mode
python scripts/mindmap_workflow.py <课件路径> [输出路径]
# AI-enhanced mode (recommended for complex courseware)
python scripts/mindmap_workflow.py <课件路径> <输出路径> --ai <结构JSON>
Step 6: XMind Import
Instruct user to import the generated Word document into XMind:
- Open XMind
- File → Import → select the Word document
- Heading styles auto-map to mindmap hierarchy
Environment Setup
Python path (managed, isolated):
C:UsersHUAWEI.workbuddybinariespythonenvsdefaultScriptspython.exe
Required packages: python-pptx, python-docx
(installed in the managed venv above)
If venv doesn't exist:
"C:UsersHUAWEI.workbuddybinariespythonversions3.13.12python.exe" -m venv "C:UsersHUAWEI.workbuddybinariespythonenvsdefault"
"C:UsersHUAWEI.workbuddybinariespythonenvsdefaultScriptspip.exe" install python-pptx python-docx
AI-Enhanced Mode
For complex courseware (physics, math with formulas), automatic rule-based extraction produces poor results. Use AI-enhanced mode:
- Extract raw PPT content first
- AI analyzes content and constructs a structured JSON:
{ "章节标题": { "小节标题": { "知识点": ["细分考点1", "细分考点2"] } } } - Save JSON, then run:
python scripts/mindmap_workflow.py <课件> <输出> --ai <结构.json>
This produces much higher quality mindmaps because AI can:
- Reconstruct fragmented formulas into complete knowledge points
- Identify logical groupings not marked by explicit numbering
- Filter noise more effectively than regex rules
Exception Handling Summary
| Scenario | Response |
|---|---|
| Image file (PNG/JPG) | "请上传课件Word或PPT文件" |
| PDF/TXT/CSV/other | "请上传课件Word或PPT文件" |
| File not found | "文件不存在:{path}" |
| Empty file (0 bytes) | "文件无效:文件为空" |
| Insufficient content | "文件无效:文档内容过少,无法提取有效知识点" |
| Corrupt PPTX | "文件格式损坏或非标准PPT格式" |
Resources
scripts/
mindmap_workflow.py— Complete automation workflow script with file validation, content extraction, knowledge structure analysis, and Word document generation. Supports both auto-analysis and AI-enhanced modes.
references/
knowledge_structure_rules.md— Regex patterns for chapter/section detection, noise filtering rules, font-size heuristics, XMind import specifications, and supported file format reference.




