Skip to content

Yuan1z0825/nature-skills / skills/nature-paper-to-patent

nature-paper-to-patent

Flagged

Turn research papers or inventor materials into evidence-grounded Chinese invention patent drafts and technical disclosures. Use for 技术交底书、专利撰写、现有技术对比 and Chinese DOCX patent packages; not general manuscript writing.

FileKindSize
README.mdmarkdown2.9 KB
README_EN.mdmarkdown3.3 KB
SKILL.mdskill md4.5 KB
agents/openai.yamlconfig248 B
evals/evals.jsonconfig1.5 KB
manifest.yamlconfig3.1 KB
references/cn-patent-drafting-guide.mdmarkdown8.0 KB
references/corpus-derived-patterns.mdmarkdown3.5 KB
references/corpus-pair-audit.mdmarkdown2.9 KB
references/disclosure/correction_handler.mdmarkdown2.8 KB
references/disclosure/disclosure_builder.mdmarkdown12.1 KB
references/disclosure/disclosure_preview.mdmarkdown917 B
references/disclosure/disclosure_self_check.mdmarkdown5.9 KB
references/disclosure/intake.mdmarkdown943 B
references/disclosure/iteration_context.mdmarkdown4.3 KB
references/disclosure/merger.mdmarkdown3.4 KB
references/disclosure/patent-disclosure-skill-MIT-LICENSE.txtmarkdown1.0 KB
references/disclosure/patent_points_analyzer.mdmarkdown951 B
references/disclosure/prior_art_search.mdmarkdown10.4 KB
references/disclosure/project_scan.mdmarkdown3.6 KB
references/disclosure/template_reference.mdmarkdown9.2 KB
references/disclosure/tooling.mdmarkdown16.2 KB
references/draft-schema.mdmarkdown9.0 KB
references/patent-figure-guide.mdmarkdown2.9 KB
requirements.txtmanifest121 B
scripts/audit_claims.pyscript6.4 KB
scripts/build_patent_package.pyscript6.5 KB
scripts/disclosure/cnipa_epub_crawler.pyscript10.7 KB
scripts/disclosure/cnipa_epub_parse.pyscript8.8 KB
scripts/disclosure/cnipa_epub_search.pyscript5.9 KB
scripts/disclosure/docx_to_md.pyscript3.7 KB
scripts/disclosure/iteration_dialog_log.pyscript3.2 KB
scripts/disclosure/math_render.pyscript12.7 KB
scripts/disclosure/md_to_docx.pyscript32.2 KB
scripts/disclosure/mermaid_render.pyscript15.2 KB
scripts/disclosure/package-lock.jsonmanifest84.4 KB
scripts/disclosure/package.jsonmanifest279 B
scripts/disclosure/pptx_to_md.pyscript4.9 KB
scripts/disclosure/requirements-cnipa.txtmarkdown172 B
scripts/extract_pdf_text.pyscript2.3 KB
scripts/init_patent_project.pyscript3.1 KB
scripts/math_to_omml.pyscript4.8 KB
scripts/render_flowchart_svg.pyscript14.3 KB
scripts/render_patent_docx.pyscript10.3 KB
scripts/validate_patent_draft.pyscript14.6 KB
static/core/output-contract.mdmarkdown2.0 KB
static/core/principles.mdmarkdown1016 B
static/core/workflow.mdmarkdown3.8 KB
static/fragments/invention/algorithm-software.mdmarkdown366 B
static/fragments/invention/apparatus-system.mdmarkdown288 B
static/fragments/invention/mixed.mdmarkdown255 B
static/fragments/invention/process-material.mdmarkdown278 B
static/fragments/source/mixed-project.mdmarkdown369 B
static/fragments/source/pasted-text.mdmarkdown316 B
static/fragments/source/pdf-text.mdmarkdown290 B
static/fragments/source/scanned-pdf.mdmarkdown272 B
static/fragments/task/claim-set.mdmarkdown249 B
static/fragments/task/disclosure-analysis.mdmarkdown236 B
static/fragments/task/disclosure-iteration.mdmarkdown1005 B
static/fragments/task/full-draft.mdmarkdown247 B
static/fragments/task/paper-patent-audit.mdmarkdown280 B
static/fragments/task/technical-disclosure.mdmarkdown1.5 KB
tests/test_audit_claims.pyscript1.6 KB
tests/test_inline_math_paren.pyscript1.7 KB
tests/test_math_to_omml_superscript.pyscript2.2 KB
tests/test_md_to_docx_source_overwrite.pyscript1.4 KB
tests/test_mermaid_render.pyscript2.3 KB
tests/test_validation.pyscript6.0 KB
tests/test_validation_figure_node_ids.pyscript614 B

scripts/disclosure/cnipa_epub_search.py

View on GitHub
# -*- coding: utf-8 -*-
"""
国知局公布站「检索 + 解析」一步完成:内存中持有结果页 HTML,**默认不落盘**。

内部调用 ``cnipa_epub_crawler.search_epub_keyword``(等同先 ``fetch_epub_result_html`` 再
``parse_search_result_html``)。

**输出约定**(便于 Agent 抓取且不触发误判降级):

- **stdout**:**仅一行** ``EPUB_HITS_JSON:`` + JSON 数组(UTF-8,含中文标题与 ``abstract``)。
- **stderr**:``EPUB_MERGE:`` / ``EPUB_NOTE:`` / ``EPUB_HINT:`` 等为 **ASCII**,减轻 PowerShell 把
  含中文的 stderr 当成 ``NativeCommandError``,以及 ``2>&1`` 合并流时的乱码。stdout 上 JSON 仍为 UTF-8
  中文。启动时 ``reconfigure`` UTF-8。

**检索词拆分(仅按空白)**:命令行中所有参数会按 **Python 空白规则**(`str.split()`)拆成多段;
**一段一查**,结果按公开号去重合并。**不在本脚本内**对长中文做自动分词或拆字——**相关度高的语义化
检索单位须在 Agent 生成 Bash 前完成**(见 ``references/disclosure/prior_art_search.md``「国知局检索词(生成阶段必做)」)。
若需**整句一次**向公布站提交(站内 AND),请改用 ``cnipa_epub_crawler.py`` 单传一句。

需已安装:pip install -r scripts/disclosure/requirements-cnipa.txt && python -m playwright install chromium

用法:

  python scripts/disclosure/cnipa_epub_search.py 词1
  python scripts/disclosure/cnipa_epub_search.py "短语 含 空格"
  python scripts/disclosure/cnipa_epub_search.py 词甲 词乙 词丙

**必须**至少有一个非空检索词;**不设默认**。

若需将结果页 HTML 保存到磁盘,请改用 ``cnipa_epub_crawler.py``;若只对已有 HTML 文件做解析,
请用 ``cnipa_epub_parse.py``。

环境变量:与 ``cnipa_epub_crawler.py`` 相同(如 ``EPUB_WAF_MAX_WAIT_SEC``、``PLAYWRIGHT_HEADED``)。
"""
from __future__ import annotations

import json
import os
import sys

if hasattr(sys.stdout, "reconfigure"):
    sys.stdout.reconfigure(encoding="utf-8")
if hasattr(sys.stderr, "reconfigure"):
    sys.stderr.reconfigure(encoding="utf-8")

_MAX_TERMS = 8


def _ensure_utf8_stdio() -> None:
    """在 Windows 等环境下将 stdout/stderr 设为 UTF-8,避免中文 JSON 在终端乱码导致误判检索失败。"""
    for stream in (sys.stdout, sys.stderr):
        try:
            if hasattr(stream, "reconfigure"):
                stream.reconfigure(encoding="utf-8", errors="replace")
        except (OSError, ValueError, TypeError):
            pass


def _terms_from_argv(argv: list[str]) -> list[str]:
    """从所有 argv 片段中按空白拆分(等价 str.split,连续空格视为一次分隔)。"""
    terms: list[str] = []
    for a in argv:
        for part in (a or "").split():
            p = part.strip()
            if p:
                terms.append(p)
    return terms


def _dedupe_hits(hits_lists: list) -> list:
    from cnipa_epub_parse import EpubSearchHit

    seen: set[str] = set()
    out: list[EpubSearchHit] = []
    for hits in hits_lists:
        for h in hits:
            key = h.pub_number or h.link or (h.title or "")[:120]
            if key in seen:
                continue
            seen.add(key)
            out.append(h)
    return out


def _usage() -> None:
    print("usage: python scripts/disclosure/cnipa_epub_search.py <term> [more terms...]", file=sys.stderr)
    print(
        "whitespace splits to multiple terms; one Playwright run per term; merge by pub_number.",
        file=sys.stderr,
    )
    print('example: python scripts/disclosure/cnipa_epub_search.py "batch 调度 异构"', file=sys.stderr)


def main(argv: list[str] | None = None) -> int:
    _ensure_utf8_stdio()
    argv = argv if argv is not None else sys.argv[1:]
    terms = _terms_from_argv(argv)
    if not terms:
        _usage()
        return 2
    if len(terms) > _MAX_TERMS:
        print(
            "ERROR: too many terms after split (%d > %d); shorten or run in batches."
            % (len(terms), _MAX_TERMS),
            file=sys.stderr,
        )
        return 2

    os.environ.setdefault("EPUB_WAF_MAX_WAIT_SEC", "180")

    try:
        import playwright  # noqa: F401
    except ImportError:
        print(
            "ERROR: pip install -r scripts/disclosure/requirements-cnipa.txt && python -m playwright install chromium",
            file=sys.stderr,
        )
        return 1

    from cnipa_epub_crawler import search_epub_keyword
    from cnipa_epub_parse import hits_to_jsonable

    multi = len(terms) > 1
    last_html = ""
    all_batches: list = []

    try:
        for kw in terms:
            html, hits = search_epub_keyword(kw)
            last_html = html
            all_batches.append(hits)
    except Exception as e:
        print("CNIPA_EPUB_ERROR:", e, file=sys.stderr)
        return 1

    if multi:
        hits = _dedupe_hits(all_batches)
        print(
            "EPUB_MERGE: terms=%d merged_hits=%d" % (len(terms), len(hits)),
            file=sys.stderr,
            flush=True,
        )
    else:
        hits = all_batches[0]

    if not hits and last_html and len(last_html) < 20_000:
        if multi:
            print(
                "EPUB_HINT: 0 hits after multi-term run; try broader terms or WebSearch (prior_art_search.md)",
                file=sys.stderr,
                flush=True,
            )
        else:
            print(
                "EPUB_HINT: 0 hits; try more terms (space-separated) or WebSearch",
                file=sys.stderr,
                flush=True,
            )

    print(
        "EPUB_NOTE: html_bytes=%d disk=0" % len(last_html),
        file=sys.stderr,
        flush=True,
    )
    # 仅此一行写入 stdout,供管道/Agent 稳定解析(勿混入多行文本,避免误判未命中)
    print(
        "EPUB_HITS_JSON:",
        json.dumps(hits_to_jsonable(hits), ensure_ascii=False),
        flush=True,
    )
    return 0


if __name__ == "__main__":
    raise SystemExit(main())
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