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/math_to_omml.py

View on GitHub
#!/usr/bin/env python3
"""Convert a LaTeX equation into editable Word Office Math (OMML)."""

from copy import deepcopy
from xml.etree import ElementTree

from docx.oxml import OxmlElement
from docx.oxml.ns import qn


MATHML_NS = "{http://www.w3.org/1998/Math/MathML}"


def _element(name: str):
    return OxmlElement(f"m:{name}")


def _text_run(text: str):
    run = _element("r")
    properties = _element("rPr")
    style = _element("sty")
    style.set(qn("m:val"), "p")
    properties.append(style)
    run.append(properties)
    value = _element("t")
    value.text = text
    run.append(value)
    return run


def _append_children(target, source) -> None:
    if source.text and source.text.strip():
        target.append(_text_run(source.text.strip()))
    for child in source:
        _append_mathml(target, child)
        if child.tail and child.tail.strip():
            target.append(_text_run(child.tail.strip()))


def _script(target, node, kind: str) -> None:
    result = _element(kind)
    expression = _element("e")
    sub = _element("sub")
    sup = _element("sup")
    children = list(node)
    if children:
        _append_mathml(expression, children[0])
    if len(children) > 1:
        _append_mathml(sup if kind == "sSup" else sub, children[1])
    if len(children) > 2:
        _append_mathml(sup, children[2])
    result.append(expression)
    if kind in {"sSub", "sSubSup"}:
        result.append(sub)
    if kind in {"sSup", "sSubSup"}:
        result.append(sup)
    target.append(result)


def _append_mathml(target, node) -> None:
    tag = node.tag.removeprefix(MATHML_NS)
    children = list(node)

    if tag in {"math", "mrow", "mstyle", "semantics", "annotation"}:
        _append_children(target, node)
    elif tag in {"mi", "mn", "mo", "mtext"}:
        target.append(_text_run("".join(node.itertext())))
    elif tag == "mfrac":
        fraction = _element("f")
        numerator = _element("num")
        denominator = _element("den")
        if children:
            _append_mathml(numerator, children[0])
        if len(children) > 1:
            _append_mathml(denominator, children[1])
        fraction.extend((numerator, denominator))
        target.append(fraction)
    elif tag == "msub":
        _script(target, node, "sSub")
    elif tag == "msup":
        _script(target, node, "sSup")
    elif tag in {"msubsup", "munderover"}:
        _script(target, node, "sSubSup")
    elif tag == "munder":
        _script(target, node, "sSub")
    elif tag == "mover":
        _script(target, node, "sSup")
    elif tag == "msqrt":
        radical = _element("rad")
        properties = _element("radPr")
        hide_degree = _element("degHide")
        hide_degree.set(qn("m:val"), "1")
        properties.append(hide_degree)
        degree = _element("deg")
        expression = _element("e")
        _append_children(expression, node)
        radical.extend((properties, degree, expression))
        target.append(radical)
    elif tag == "mroot":
        radical = _element("rad")
        degree = _element("deg")
        expression = _element("e")
        if children:
            _append_mathml(expression, children[0])
        if len(children) > 1:
            _append_mathml(degree, children[1])
        radical.extend((degree, expression))
        target.append(radical)
    elif tag == "mfenced":
        delimiter = _element("d")
        properties = _element("dPr")
        begin = _element("begChr")
        begin.set(qn("m:val"), node.attrib.get("open", "("))
        end = _element("endChr")
        end.set(qn("m:val"), node.attrib.get("close", ")"))
        properties.extend((begin, end))
        expression = _element("e")
        _append_children(expression, node)
        delimiter.extend((properties, expression))
        target.append(delimiter)
    elif tag == "mtable":
        matrix = _element("m")
        for row_node in children:
            row = _element("mr")
            for cell_node in list(row_node):
                cell = _element("e")
                _append_children(cell, cell_node)
                row.append(cell)
            matrix.append(row)
        target.append(matrix)
    elif tag in {"mtr", "mtd"}:
        _append_children(target, node)
    elif tag == "mspace":
        target.append(_text_run(" "))
    else:
        _append_children(target, node)


def latex_to_omml(latex: str):
    try:
        from latex2mathml.converter import convert
    except ImportError as error:
        raise RuntimeError(
            "Native equations require latex2mathml: py -3 -m pip install latex2mathml"
        ) from error

    mathml = ElementTree.fromstring(convert(latex))
    paragraph = _element("oMathPara")
    math = _element("oMath")
    _append_mathml(math, mathml)
    paragraph.append(math)
    return paragraph


def clone_omml(element):
    return deepcopy(element)
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