Metadata-Version: 2.4
Name: normpare
Version: 0.2.0
Summary: Compare two editions of a technical standard: changes, per-chapter summaries and a synopsis — deterministic, plus optional AI interpretation.
License: MIT
License-File: LICENSE
Keywords: standards,standard,diff,compare,synopsis,regulatory,docx,pdf
Author: Christian Ehlert
Author-email: christian.ehlert@mailbox.org
Requires-Python: >=3.13,<3.14
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Text Processing :: Linguistic
Provides-Extra: anthropic
Provides-Extra: embeddings
Requires-Dist: anthropic (>=0.40,<1.0) ; extra == "anthropic"
Requires-Dist: einops (>=0.8,<0.9) ; extra == "embeddings"
Requires-Dist: lxml (>=5.0,<6.0)
Requires-Dist: numpy (>=2.1,<3.0)
Requires-Dist: pillow (>=12.3.0,<13.0.0)
Requires-Dist: pymupdf (>=1.24,<2.0)
Requires-Dist: python-docx (>=1.1,<2.0)
Requires-Dist: python-pptx (>=1.0,<2.0)
Requires-Dist: scipy (>=1.14,<2.0)
Requires-Dist: sentence-transformers (>=3.0,<4.0) ; extra == "embeddings"
Project-URL: Documentation, https://ce1ectric.github.io/normpare/
Project-URL: Homepage, https://github.com/Ce1ectric/normpare
Project-URL: Repository, https://github.com/Ce1ectric/normpare
Description-Content-Type: text/markdown

# normpare

**Find out what actually changed between two editions of a technical standard.**

When a standard is revised, the publisher rarely tells you precisely what changed. You get a
new PDF of several hundred pages and are left to compare it against the old one by hand.
`normpare` does that comparison for you: it reads both editions, matches them chapter by
chapter and paragraph by paragraph, and reports every change — new requirements, deleted
ones, changed limit values, reworded passages, moved sections, edited tables.

The comparison itself is **deterministic**: same inputs, same output, every time, with no AI
involved. On top of that you can optionally switch on an **AI interpretation** that explains
each change in plain language. The pipeline records what happened structurally; the AI adds
what happened to the statement, whether the requirement got stricter or looser, and which
parts of the standard are touched. Every interpretation of a change, a table or a figure
carries a verbatim quote from the source, and normpare checks that the quote really exists;
values the AI reports for a table are checked against the table's cells. Failed quotes,
failed value checks and contradictions between the interpretation and the facts are
collected in a review queue — marked, never silently corrected.

## What you get

- An annotated **HTML** version of the new edition: changes colour-coded in place, with a
  summary per chapter, cell-level table diffs and, for DOCX sources, embedded figures.
- Two **Word synopses** — a deterministic, tabular old ↔ new comparison, and (if AI is on) a
  readable one with one entry per chapter: an overview, then every interpreted change.
- A **PowerPoint** draft of the key changes, machine-readable **JSON** for every stage,
  **tables as CSV**, and figures as image files when the source is a DOCX.
- **Working lists**: every interpreted change as a CSV row with its axes and its section in
  both editions, the changed values with their section and class, the same material grouped
  by affected component, and review lists of what needs a human look.

## Installation

Requires **Python 3.13**.

```bash
pip install normpare                      # deterministic comparison, OpenAI-compatible AI
pip install "normpare[anthropic]"         # + AI interpretation via Anthropic
pip install "normpare[embeddings]"        # + optional embedding-based alignment
```

## Usage

Two files in, one directory out:

```bash
# deterministic only
normpare compare --old standard_2019.pdf --new standard_2026.docx --out result/ --no-llm

# with AI interpretation via Anthropic (needs normpare[anthropic];
# key in ANTHROPIC_API_KEY or a file .api_key)
normpare compare --old standard_2019.pdf --new standard_2026.docx --out result/

# with any OpenAI-compatible endpoint, e.g. DeepSeek (key in LLM_API_KEY or .api_key)
normpare compare --old standard_2019.pdf --new standard_2026.docx --out result/ \
    --provider openai_compatible --base-url https://api.deepseek.com --model deepseek-v4-flash
```

PDF and DOCX are both supported, and mixing them is fine. Without an API key the run is
purely deterministic; the AI prompts are exported so you can paste them into a chat instead.
Answers are cached, so an interrupted run resumes where it stopped.

From Python:

```python
import normpare

result = normpare.compare(
    old="standard_2019.pdf",
    new="standard_2026.docx",
    out_dir="result/",
    use_llm=False,          # True + an API key => AI interpretation
    language="de",          # language of the AI's free-text output
)
print(result.html, result.synopse_det)
```

Other useful flags: `--batch` (send the interpretation as one Anthropic batch, about half the
price) and `--provider` (Anthropic, OpenAI, Azure, Google, Mistral, Groq, Together,
OpenRouter, a local Ollama server, or any OpenAI-compatible endpoint). With any provider
other than `anthropic`, name the model with `--model`.

## Status

Version 0.2.0 has been run end to end over three complete standard revisions with 1,100 to
2,400 changes each: every change sent to the model was answered, and 98 – 99 % of the AI's
quotes were verified in the source. In a manual spot check of fifteen central changes, made
on the runs just before the release, every value change found by the deterministic diff was
right; the errors were an AI statement about a table and a false alarm of the modality
detection. The interpretation is a reading aid with verified quotes, not a legal
assessment.

## Documentation

Full documentation — how to read the results, how the pipeline works, how to pick an AI
model: <https://ce1ectric.github.io/normpare/>

Changes between versions:
[CHANGELOG.md](https://github.com/Ce1ectric/normpare/blob/main/CHANGELOG.md)

## License

[MIT](https://github.com/Ce1ectric/normpare/blob/main/LICENSE) © 2026 Christian Ehlert

