Word Comments Extractor
by @tomyan-zhang
Extract comments from Word documents and format them into standardized review opinions. Auto-matches page numbers, agent-powered semantic polishing. Designed...
clawhub install word-comments-extractorπ About This Skill
name: word-comments-extractor description: Extract comments from Word documents and format them into standardized review opinions. Auto-matches page numbers, agent-powered semantic polishing. Designed for investment banking QC, legal review, and document audit scenarios. platforms: ["win32"] binaries: ["Microsoft Word"] install: steps: - description: "Install pywin32 Python package" command: "python -m pip install pywin32" note: "Microsoft Word must be installed manually by the user. This skill requires Word COM interface for page number retrieval."
Word Comments Extractor
Overview
Extract comments from Word (.docx) documents and format them into standardized review opinions. The script handles data extraction (comment text, anchor text, page numbers) and outputs structured JSON. The agent then performs semantic polishing to produce professional, publication-ready review opinions.
Core capabilities:
Architecture
extract_comments.py): Handles all data extraction locally. Unpacks the .docx file (using Python's built-in zipfile), parses XML to extract comments and anchor text, retrieves page numbers via Word COM. Outputs JSON. No external dependencies beyond pywin32.Usage
Step 1: Run the extraction script
python extract_comments.py
The script takes a single argument β the path to the .docx file. It handles unpacking internally.
Output is a JSON array, each element containing:
index: Comment sequence numberpage: Page numbercomment_text: Original comment textanchor_text: The document text that the comment is attached toStep 2: Agent polishes and outputs
After receiving the JSON data, the agent processes each comment:
#### 2.1 Distill description
Extract a concise, precise content description from the anchor text for the "regarding XX" part of the output.
Requirements:
Examples:
#### 2.2 Polish comment content
Core principle: Understand intent, rewrite professionally, never mechanically concatenate.
Rules:
1. Understand the commenter's true intent
2. Combine with anchor text context
3. Neither expand nor reduce
4. Professional language standards
5. Prohibited error patterns
#### 2.3 Polishing examples
| Original comment | Anchor text context | Correct polishing | |---------|----------------|---------| | The reason for the price decline wasn't mentioned | Sensor gross margin decline, unit price decline | Please supplement the specific reasons for the average unit price decline | | The wording here isn't very clear, it's actually more about product mix or specific products, specific customers having a bigger impact | Oxygen sensor revenue fluctuation | Please clarify the core factors driving the fluctuation: product mix, specific product characteristics, and specific customer dynamics | | Add numbering to subheadings, same below | Oxygen sensor downstream domestic substitution | Please add numbering; apply the same numbering format to all subsequent subheadings | | The performance improvement compared to externally sourced chip modules needs to be mentioned here | MEMS pressure sensor cost | Please supplement the specific performance improvements of the self-developed chip module compared to externally sourced modules | | After reading, the comparison doesn't convey much information. Are there more in-depth capacity parameter comparisons? | Capacity parameter comparison table | The current comparison lacks depth. Please supplement with a more detailed cross-comparison of core capacity parameters | | Typo? | Text contains character error | Please verify and correct the typo at this location | | Be more precise, make it clear this is projected | Gross margin related statement | Please ensure precise wording, explicitly stating the "projected" nature to avoid ambiguity |
Output format
Each comment formatted as:
[number]. Page [X]: Regarding [description], [polished suggestion]
Overall structure:
[comment 1]
[comment 2]
...Total: XX review opinions
================================================================================
[Page number note]
Page numbers correspond to physical pages in the document and may differ from
displayed page numbers (e.g., if the document has cover pages or table of contents
that are not numbered). If adjustment is needed, provide the offset between
physical and displayed page numbers for batch correction.
================================================================================
Output requirement: Only output the polished comment list + page number note. No additional summaries, category descriptions, or polishing explanations.
Requirements
pip install pywin32Notes
1. Page number retrieval requires Word COM interface β Microsoft Word must be installed. 2. Output page numbers are physical page numbers (counting from page 1 of the document) and may differ from displayed page numbers. 3. UTF-8 encoding is handled automatically on Windows.
π‘ Examples
Step 1: Run the extraction script
python extract_comments.py
The script takes a single argument β the path to the .docx file. It handles unpacking internally.
Output is a JSON array, each element containing:
index: Comment sequence numberpage: Page numbercomment_text: Original comment textanchor_text: The document text that the comment is attached toStep 2: Agent polishes and outputs
After receiving the JSON data, the agent processes each comment:
#### 2.1 Distill description
Extract a concise, precise content description from the anchor text for the "regarding XX" part of the output.
Requirements:
Examples:
#### 2.2 Polish comment content
Core principle: Understand intent, rewrite professionally, never mechanically concatenate.
Rules:
1. Understand the commenter's true intent
2. Combine with anchor text context
3. Neither expand nor reduce
4. Professional language standards
5. Prohibited error patterns
#### 2.3 Polishing examples
| Original comment | Anchor text context | Correct polishing | |---------|----------------|---------| | The reason for the price decline wasn't mentioned | Sensor gross margin decline, unit price decline | Please supplement the specific reasons for the average unit price decline | | The wording here isn't very clear, it's actually more about product mix or specific products, specific customers having a bigger impact | Oxygen sensor revenue fluctuation | Please clarify the core factors driving the fluctuation: product mix, specific product characteristics, and specific customer dynamics | | Add numbering to subheadings, same below | Oxygen sensor downstream domestic substitution | Please add numbering; apply the same numbering format to all subsequent subheadings | | The performance improvement compared to externally sourced chip modules needs to be mentioned here | MEMS pressure sensor cost | Please supplement the specific performance improvements of the self-developed chip module compared to externally sourced modules | | After reading, the comparison doesn't convey much information. Are there more in-depth capacity parameter comparisons? | Capacity parameter comparison table | The current comparison lacks depth. Please supplement with a more detailed cross-comparison of core capacity parameters | | Typo? | Text contains character error | Please verify and correct the typo at this location | | Be more precise, make it clear this is projected | Gross margin related statement | Please ensure precise wording, explicitly stating the "projected" nature to avoid ambiguity |
π Tips & Best Practices
1. Page number retrieval requires Word COM interface β Microsoft Word must be installed. 2. Output page numbers are physical page numbers (counting from page 1 of the document) and may differ from displayed page numbers. 3. UTF-8 encoding is handled automatically on Windows.