Skip to content

CSlawyer1985/legal-skillhub / skills/archive-ip-pdfs

archive-ip-pdfs

Verified

知识产权官文自动归档技能。当用户需要批量处理知识产权官文 PDF 文件(专利、商标、软著),将其解析、归档、生成报表时触发。关键词:归档、知识产权、PDF、专利、商标、软著、官文。

知识产权官文自动归档技能

功能概述

本技能用于批量处理知识产权官文 PDF 文件,自动完成以下工作:

  1. PDF 解析与归档:扫描指定目录中的 PDF 文件,识别文件类型(专利/商标/软著),提取关键字段(申请号、通知书名称、权利人等),按命名规则重命名并归档到组织化目录结构中
  2. 文件路径同步:根据标识号、法律状态、当前权利人等信息,将归档文件重新组织到更清晰的目录结构中
  3. 汇总报表生成:基于归档数据生成汇总报表,每个知识产权仅保留一条最新状态记录

调用指令

使用 subagent 执行以下命令(工作目录设为 SKILL.md 所在目录):

python -m scripts.run_archive --input <目标文件夹> [--output <输出文件夹>]

参数说明

参数必选说明
--input是待处理的 PDF 文件所在目录,脚本会递归扫描该目录下所有 .pdf 文件
--output否输出根目录。若不指定,自动在输入目录的父目录下创建 ip_archives 文件夹

Agent 操作步骤

  1. 确认用户提供了目标文件夹路径(--input 参数)
  2. 若用户未指定输出路径,使用默认值(无需传 --output)
  3. Python 环境检测(关键步骤,必须在执行归档命令前完成): a. 先执行 where.exe python 查找系统中的 Python 可执行文件 b. 注意:Windows 系统中 C:\Users\...\AppData\Local\Microsoft\WindowsApps\python.exe 是 Windows Store 重定向程序,不能用于执行脚本,必须跳过 c. 选取非 WindowsApps 路径下的 Python(如 C:\Users\...\AppData\Local\Python\bin\python.exe),使用完整路径调用 d. 执行 <Python路径> -c "import pdfplumber; print('OK')" 验证 pdfplumber 可用;若不可用则执行 <Python路径> -m pip install pdfplumber pymupdf PyPDF2
  4. 将工作目录设为 SKILL.md 所在目录,使用步骤 3 中确认的 Python 完整路径调用 subagent 执行归档命令
  5. 将脚本输出的汇总报告展示给用户

系统架构

系统由以下核心模块组成,按执行顺序协同工作:

scripts/
├── __init__.py          # 包初始化,声明模块列表
├── __main__.py          # 包入口,支持 python -m scripts 运行
├── config.py            # 全局配置(目录路径、CSV列定义)
├── csv_manager.py       # CSV 文件增删改查操作
├── pdf_parser.py        # PDF 文本提取与字段解析(核心模块)
├── legal_status.py      # 法律状态判定与更新
├── main.py              # 系统入口(调度三个核心脚本)
├── run_archive.py       # CLI 入口(支持命令行参数)
├── script1_process.py   # 脚本1:扫描处理(PDF解析→归档→写入CSV)
├── script2_sync.py      # 脚本2:文件路径同步(按标识号重组目录结构)
└── script3_report.py    # 脚本3:报表生成(汇总最新状态)

执行流程

输入PDF文件 → 脚本1(解析归档) → 脚本2(路径同步) → 脚本3(报表生成) → 输出结果
     │              │                  │                  │
     │              ├─ PDF文本提取      ├─ 计算目标路径     ├─ 专利报表
     │              ├─ 类型识别         ├─ 文件移动         ├─ 商标报表
     │              ├─ 字段解析         ├─ 路径更新         └─ 软著报表
     │              ├─ 幂等性检查       └─ 空目录清理
     │              ├─ 文件复制重命名
     │              ├─ CSV记录写入
     │              └─ 法律状态更新
     └─ 失败文件 → failed/ 目录

核心模块说明

pdf_parser.py — PDF 解析模块

  • 支持三种 PDF 引擎:pdfplumber(优先)→ PyMuPDF(fitz) → PyPDF2(降级)
  • 识别三大主类型:专利文件、商标文件、软著文件
  • 识别八种子类型:专利通知书、专利证书、专利登记簿副本、商标通知书、商标注册证、商标注册申请书、软著受理通知书、软著证书
  • 按命名模板生成规范化文件名

legal_status.py — 法律状态判定模块

  • 专利法律状态四级优先级:专利证书 → 通知书映射 → 登记簿副本 → 手续合格通知书
  • 商标法律状态三级优先级:注册证 → 初审公告 → 最新有效映射
  • 软著法律状态两级优先级:软著证书 → 最新有效映射
  • 自动计算状态变更历史(以"→"连接)
  • 自动计算专利权人变更记录

csv_manager.py — CSV 管理模块

  • 自动检测编码(UTF-8-BOM / UTF-8 / GBK / GB18030 / Latin-1)
  • 写入统一使用 UTF-8-BOM 编码,确保 Excel 兼容
  • 支持初始化、读取、覆写、追加、更新、查找、路径批量更新等操作

输出目录结构

<输出目录的父目录>/
├── <输入文件夹>/      ← --input 指定的目录
├── <输出目录>/        ← --output 指定的目录(默认 ip_archives)
│   ├── archives/          # 归档的 PDF 文件,按类型组织
│   │   ├── 专利/          # 专利类文件,三级分类:专利权人/法律状态/专利号子文件夹
│   │   │   ├── 公司A/     # 第一级:按当前权利人分组
│   │   │   │   ├── 授权/  # 第二级:按法律状态分组
│   │   │   │   │   └── CN202010123456.1-发明-授权-公司A/  # 第三级:专利号-专利类型-法律状态-当前专利权人
│   │   │   │   └── 审/
│   │   │   │       └── CN202020123456.2-实用新型-实审-公司A/
│   │   │   └── 公司B/
│   │   │       └── 授权/
│   │   │           └── CN202030123456.3-外观设计-授权-公司B/
│   │   ├── 商标/          # 商标类文件,子文件夹命名:标识号-商标申请类别-法律状态-当前权利人
│   │   └── 软著/          # 软著类文件,二级分类:当前权利人/标识号-法律状态-当前权利人
│   │       ├── 公司A/     # 第一级:按当前权利人分组
│   │       │   └── 2023R11S1234567-受理申请-公司A/  # 第二级:标识号-法律状态-当前权利人
│   │       └── 公司B/
│   │           └── 2024SR1234567-登记下证-公司B/
│   ├── csv/               # CSV 数据文件
│   │   ├── patent_files_archive.csv      # 专利归档明细
│   │   ├── patent_report.csv             # 专利汇总报表
│   │   ├── trademark_files_archive.csv   # 商标归档明细
│   │   ├── trademark_report.csv          # 商标汇总报表
│   │   ├── software_files_archive.csv    # 软著归档明细
│   │   └── software_report.csv           # 软著汇总报表
│   └── logs/              # 日志文件
│       ├── <timestamp>system.log  # 系统运行日志(每轮一个)
│       └── <timestamp>.json  # 每次处理的 JSON 日志
└── failed/              # 处理失败的 PDF 文件(与输入/输出目录同级)

法律状态判定规则

专利法律状态

法律状态判定条件
授权存在专利证书且无终止通知书
失效存在专利证书且有终止通知书
受理专利申请受理通知书,或仅有手续合格通知书
实审进入实质审查、审查意见通知书、补正通知书
驳回驳回决定
复审复审决定书、复审通知书、复审请求受理通知书
办登授予专利权通知书、办理登记手续通知书
撤回视为撤回通知书、视为放弃取得专利权通知书、撤回专利申请手续合格通知书
未知无法通过以上规则判定

商标法律状态

法律状态判定条件
已注册存在商标注册证
初审公告存在初步审定公告通知书
受理商标注册申请受理/缴费通知书
驳回商标驳回通知书
部分驳回商标部分驳回通知书
复审决定商标驳回复审决定书
申请中商标注册申请书
续展续展注册相关通知书/证明

软著法律状态

法律状态判定条件
登记下证存在软著证书
受理申请软著受理通知书

幂等性判断规则

系统在处理 PDF 文件时会进行幂等性检查,避免重复归档。不同文件类型的去重键如下:

文件类型去重键
专利通知书申请号 + 通知书名称 + 发文序号
专利证书申请号 + 子类型
专利登记簿副本申请号 + 子类型 + 发文日期
商标通知书申请号 + 通知书名称 + 发文编号
商标注册证注册号 + 子类型
商标注册申请书代理文号 + 子类型
软著受理通知书受理号 + 子类型
软著证书登记号 + 子类型

依赖

  • Python 3.10+
  • pdfplumber(推荐,PDF 文本提取)
  • PyMuPDF / fitz(备选 PDF 引擎)
  • PyPDF2(备选 PDF 引擎)

至少需要安装 pdfplumber、PyMuPDF、PyPDF2 中的一个。

canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill.Stars: 198kUpdated Claude CodeCodexVerifiedInstall