npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

patent-data-parser

v1.0.0

Published

解析CNIPA/WIPO公开专利XML数据,输出结构化JSON

Readme

Patent Data Parser

解析 CNIPA(国家知识产权局)及 WIPO 公开专利 XML 数据,输出结构化 JSON,适用于专利数据采集、分析和入库。

功能

  • 解析 CNIPA 公开专利 XML(cn-patent-document
  • 解析专利申请文件 XML(cn-application-body
  • 兼容 WIPO ST.36 格式
  • 提取著录信息(申请号、公开号、IPC分类、申请人、发明人等)
  • 提取摘要、权利要求、说明书全文
  • 自动识别独立/从属权利要求
  • 支持批量解析整个目录
  • 输出扁平化 JSON(方便数据库导入)
  • TypeScript 编写,类型安全

安装

npm install patent-data-parser

快速开始

import { PatentDataParser } from 'patent-data-parser';

const parser = new PatentDataParser();

// 解析单个文件
const patent = parser.parseFile('CN119000001A.xml');

console.log(patent.bibliographic.title);       // 发明名称
console.log(patent.bibliographic.applicants);   // 申请人
console.log(patent.bibliographic.ipcClassifications); // IPC分类
console.log(patent.claims.length);              // 权利要求数
console.log(patent.abstract);                   // 摘要

// 转为扁平化 JSON
const flat = parser.toFlatJSON(patent);

批量解析

const parser = new PatentDataParser();

// 解析整个目录
const result = parser.parseDirectory('./patent-xml-files/');

console.log(`成功: ${result.stats.success}, 失败: ${result.stats.failed}`);
console.log(`耗时: ${result.stats.elapsed}ms`);

// 导出为 JSON Lines(每行一条记录)
for (const patent of result.patents) {
  const flat = parser.toFlatJSON(patent);
  console.log(JSON.stringify(flat));
}

性能选项

处理大批量文件时,可关闭不需要的部分以提速:

const parser = new PatentDataParser({
  parseDescription: false,  // 不解析说明书全文
  parseClaims: true,
  parseDrawings: false,
  trimText: true,
});

输出数据结构

interface Patent {
  bibliographic: {
    title: string;              // 发明名称
    applicationNumber: string;  // 申请号
    applicationDate: string;    // 申请日
    publicationNumber: string;  // 公开号
    publicationDate: string;    // 公开日
    kind: string;               // 文献类型 A/B/U/S
    ipcClassifications: string[];
    cpcClassifications: string[];
    applicants: Entity[];
    inventors: string[];
    agency?: string;
    agents: string[];
    priorities: PriorityData[];
  };
  abstract?: string;
  claims: Claim[];
  description?: Description;
  drawings: Drawing[];
  meta: PatentMeta;
}

完整类型定义见 src/types.ts

支持的 XML 格式

| 格式 | 根元素 | 来源 | |------|--------|------| | CNIPA 公开专利 | cn-patent-document | 专利公布公告系统 | | CNIPA 申请文件 | cn-application-body | 专利电子申请 | | WIPO ST.36 | patent-document | PATENTSCOPE | | 带命名空间格式 | PatentDocumentAndRelated | 批量数据下载 |

关于

本工具是 CNIPA.AI 专利智能服务平台的开源组件。

CNIPA.AI 基于全球公开专利数据,提供专利导航、企业画像、侵权检测、价值评估、趋势预测、AI 辅助撰写六大智能服务。

License

MIT