Install
openclaw skills install @russell-yu/contract-diffCompare contract templates with scanned stamped contracts, list all differences (additions, deletions, modifications). Output as Word document for easy download. Use when user wants to verify what changes were made between a template and the final signed contract.
openclaw skills install @russell-yu/contract-diffCompare contract templates (Word/PDF) with scanned stamped contracts (PDF/images), list ALL differences, and generate a highlighted visualization showing where changes are.
For contract template (.docx):
Use python-docx to extract all text.
For contract template (.pdf):
Use PyMuPDF (fitz) to extract text.
For scanned contract (PDF or image): Use OCR with pytesseract to extract text with bounding boxes.
Split text into sentences/paragraphs and categorize:
Using difflib.SequenceMatcher with threshold:
85% similarity: treated as same
For modified content:
Output format:
# 合同比对详细报告
## 📋 文件信息
- **模板文件**: [filename]
- **盖章合同**: [filename]
## 📊 比对结果总览
- **风险等级**: 🟢低/🟡中/🔴高
- 🔴 删除内容: X 处
- 🟢 新增内容: X 处
- 🟡 修改内容: X 处
## 🔴 删除内容(模板 → 盖章合同)
1. [content...]
2. [content...]
## 🟢 新增内容(模板 → 盖章合同)
1. [content...]
2. [content...]
## 🟡 修改内容对比
| 模板内容 | 扫描件内容 | 相似度 |
|----------|------------|--------|
| ... | ... | 0.xx |
---
*⚠️ 注:比对结果基于 OCR 文字识别,可能存在误差。*
# 安装依赖
pip install python-docx PyMuPDF pillow pytesseract
# 运行比对(输出 Word 文档)
python scripts/compare.py contract_template.docx signed_contract.pdf
# 指定输出文件
python scripts/compare.py template.pdf scan.pdf -o report.docx
Required Python packages:
python-docx - for .docx filesPyMuPDF (fitz) - for PDF text extractionPillow - image processingpytesseract - OCR| 文件 | 说明 |
|---|---|
report.docx | Word 文档格式的详细比对报告(含所有差异,可直接下载) |
highlighted.png | 带高亮标注的图片(可选) |
winget install tesseract-ocr.tesseractpip install python-docx PyMuPDF pillow pytesseract
# Compare two contract files, output as Word document
python compare.py "合同模板.docx" "盖章合同.pdf" -o "详细比对报告.docx"
Output includes: