readanydoc 0.4.3__tar.gz → 0.4.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {readanydoc-0.4.3 → readanydoc-0.4.4}/CHANGELOG.md +9 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/PKG-INFO +1 -1
- {readanydoc-0.4.3 → readanydoc-0.4.4}/plugins/readanydoc/.claude-plugin/plugin.json +1 -1
- {readanydoc-0.4.3 → readanydoc-0.4.4}/plugins/readanydoc/.mcp.json +1 -1
- {readanydoc-0.4.3 → readanydoc-0.4.4}/pyproject.toml +1 -1
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/__init__.py +1 -1
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/library.py +1 -1
- readanydoc-0.4.4/readanydoc/tasks/coverage.py +445 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/tasks/field_report.py +10 -22
- readanydoc-0.4.4/tests/tasks/test_coverage.py +81 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/tasks/test_review.py +3 -3
- {readanydoc-0.4.3 → readanydoc-0.4.4}/.gitignore +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/LICENSE +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/README.md +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/docs/research/README.md +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/examples/showcase/README.md +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/plugins/readanydoc/.claude-plugin/icon.png +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/plugins/readanydoc/README.md +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/plugins/readanydoc/skills/read-documents/SKILL.md +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/api/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/api/__main__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/api/app.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/api/config.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/api/contracts.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/api/errors.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/api/inputs.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/api/schemas.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/api/service.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/api/webhooks.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/api/worker.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/bench/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/bench/catalog.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/bench/fetch.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/bench/grade.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/bench/report.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/bench/runner.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/bench/systems.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/cli.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/cvsafe.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/data/model_limits.json +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/intake/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/intake/common.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/intake/docx_reader.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/intake/errors.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/intake/heic.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/intake/legacy.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/intake/msg.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/intake/pdf.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/intake/pptx_reader.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/intake/prepare.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/intake/sheets.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/intake/sniff.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/intake/text.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/integrations/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/integrations/langchain.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/integrations/llamaindex.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/layout/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/layout/base.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/layout/cached.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/layout/claude.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/layout/onnx.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/localmodels.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/mcp_server.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/model/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/model/document.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/model_limits.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/modelspec.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/paths.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/assemble.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/assembly/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/assembly/annotations.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/assembly/furniture.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/assembly/headings.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/assembly/paragraphs.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/assembly/tables.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/base.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/checks/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/checks/common.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/checks/complete.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/checks/flags.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/checks/gridrepair.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/checks/htmlgrid.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/checks/numbers.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/checks/reread.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/common.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/figures/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/figures/layout_pictures.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/figures/locate.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/forms/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/forms/acroform.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/forms/checkbox.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/forms/fillable.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/forms/grid.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/forms/lines.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/forms/locate.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/forms/region.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/forms/rules.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/ground.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/grounding/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/grounding/align.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/grounding/confidence.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/grounding/ocr.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/grounding/sources.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/grounding/tables.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/grounding/tokens.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/intake.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/layout.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/mdblocks.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/read.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/reading/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/reading/budget.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/reading/effort_route.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/reading/escalate.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/reading/evidence.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/reading/form_prefetch.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/reading/formulas.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/reading/fusion.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/reading/handwriting.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/reading/robust.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/reading/select.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/reading/strips.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/reading/tables.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/reading/zoom.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/reading/zoom_gate.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/reading/zoom_regions.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/reading/zoom_schedule.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/regions/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/regions/assemble.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/regions/complete.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/regions/crops.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/regions/fields.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/regions/formevidence.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/regions/forms.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/regions/furniture.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/regions/match.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/regions/structure.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/regions/tables.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/request.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/shape.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/shaping/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/shaping/agentic.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/shaping/chunking.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/shaping/embed.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/shaping/merge.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/shaping/options.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/shaping/page_range.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/shaping/response.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/shaping/searchable.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/shaping/summarize.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/shaping/tables.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/tables/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/tables/evidence.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/tables/hygiene.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/tables/prefetch.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/tables/reread.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/triage.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/typing/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/typing/layout.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/typing/markup.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/pipeline/verify.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/profiles.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/readers/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/readers/anthropic_api.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/readers/anthropic_batch.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/readers/base.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/readers/batch_mode.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/readers/cached.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/readers/claude_cli.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/readers/crop_cache.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/readers/live_cache.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/readers/ocr_words.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/readers/openai_compatible.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/readers/prompts.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/readers/sizing.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/readers/usage.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/serialize/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/serialize/citations.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/serialize/reducto.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/star.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/store/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/store/cleanup.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/store/db.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/store/files.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/store/jobs.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/tasks/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/tasks/classify.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/tasks/coded.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/tasks/common.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/tasks/detect.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/tasks/edit.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/tasks/extract.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/tasks/extract_extras.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/tasks/llm.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/tasks/reply_schema.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/tasks/schema.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/tasks/split.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/textlayer.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/textnorm.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/readanydoc/trace.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/research/README.md +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/research/benchmarks/README.md +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/results/README.md +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/api/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/api/conftest.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/api/sdk_check.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/api/test_auth.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/api/test_cleanup.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/api/test_config_defaults.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/api/test_contract.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/api/test_e2e.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/api/test_jobs.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/api/test_sdk.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/api/test_webhooks.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/assembly/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/assembly/evaluate.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/assembly/synth.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/assembly/test_assembly.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/assembly/test_real_documents.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/checks/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/checks/test_checks_stage.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/checks/test_complete.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/checks/test_htmlgrid.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/checks/test_numbers.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/conftest.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/cost/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/cost/test_r3b_cost.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/figures/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/figures/test_figures.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/forms/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/forms/test_fillable.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/forms/test_grid.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/forms/test_lines_crops.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/forms/test_rules.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/grounding/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/grounding/test_grounding.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/intake/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/intake/test_intake.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/judge/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/judge/test_judge.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/reading/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/reading/test_handwriting_route.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/reading/test_live_profile.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/reading/test_reading_pipeline.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/reading/test_reading_units.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/reading/test_robustness.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/regions/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/regions/test_fields.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/regions/test_furniture.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/regions/test_regions.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/shaping/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/shaping/test_chunking.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/shaping/test_round2_options.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/shaping/test_tables.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/tables/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/tables/test_tables_round2.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/tasks/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/tasks/conftest.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/tasks/live_notes.md +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/tasks/live_smoke.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/tasks/test_edit.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/tasks/test_extract.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/tasks/test_extract_extras.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/tasks/test_extract_robust.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/tasks/test_llm.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/tasks/test_reply_schema.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/tasks/test_required_choices.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/tasks/test_schema.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/tasks/test_split_classify.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/test_bench.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/test_bench_suite.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/test_engine_final.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/test_integrations.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/test_library.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/test_localmodels.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/test_mcp_server.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/test_model.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/test_pipeline.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/test_readers.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/test_robust_fallbacks.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/test_serializer.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/test_star.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/test_ws4_ocr_prep.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/test_ws4_speed_batch.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/test_zoom_vote.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/typing/__init__.py +0 -0
- {readanydoc-0.4.3 → readanydoc-0.4.4}/tests/typing/test_typing.py +0 -0
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.4 (2026-11-19)
|
|
4
|
+
|
|
5
|
+
- Review flags values the output left out, by code with no model call: `printed_but_empty` (a field is empty but
|
|
6
|
+
the document prints a value for it that nothing took, for example a dropped billing contact) and
|
|
7
|
+
`row_not_extracted` (a list took some rows of a table and left another out). They replace
|
|
8
|
+
`list_may_be_incomplete`. On planted misses in 47 documents: 84-100% of emptied lists and 89-95% of blanked
|
|
9
|
+
fields caught, about 0.1 flags per document on real outputs. What it does not catch, and the model-based option
|
|
10
|
+
we did not build, are in the extraction guide ("Values the output left out").
|
|
11
|
+
|
|
3
12
|
## 0.4.3 (2026-11-19)
|
|
4
13
|
|
|
5
14
|
- `fill_required` (Python, CLI `--fill-required`, MCP, `settings.fill_required`): which required fields always get
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: readanydoc
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.4
|
|
4
4
|
Summary: Document parsing and extraction with vision models: an open engine around Claude (or any model), with a Reducto-compatible API
|
|
5
5
|
Project-URL: Homepage, https://arpitpatel25.github.io/ReadAnyDoc/
|
|
6
6
|
Project-URL: Repository, https://github.com/arpitpatel25/ReadAnyDoc
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "readanydoc",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "Parse PDFs, scans, photos and Office files into Markdown, and extract typed fields with a citation for every value. Open-source alternative to Reducto, on your own Anthropic key.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Unmute"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"mcpServers": {
|
|
3
3
|
"readanydoc": {
|
|
4
4
|
"command": "uvx",
|
|
5
|
-
"args": ["--from", "git+https://github.com/arpitpatel25/ReadAnyDoc@
|
|
5
|
+
"args": ["--from", "git+https://github.com/arpitpatel25/ReadAnyDoc@b461cec3f7849f74ab9b780e9aada5d5299ddd8f", "readanydoc", "mcp"]
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "readanydoc"
|
|
3
|
-
version = "0.4.
|
|
3
|
+
version = "0.4.4"
|
|
4
4
|
description = "Document parsing and extraction with vision models: an open engine around Claude (or any model), with a Reducto-compatible API"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [{ name = "readanydoc contributors" }]
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Use it as a library (``readanydoc.parse``, ``readanydoc.extract``) or run the server (``readanydoc serve``).
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
|
-
__version__ = "0.4.
|
|
6
|
+
__version__ = "0.4.4"
|
|
7
7
|
|
|
8
8
|
from .library import (Block, BoundingBox, Citation, ExtractResult, ParseResult, Usage, # noqa: E402
|
|
9
9
|
extract, parse)
|
|
@@ -108,7 +108,7 @@ class ExtractResult(BaseModel):
|
|
|
108
108
|
review: list[dict[str, Any]] = Field(default_factory=list,
|
|
109
109
|
description="with review=True: values to check, each {field, flag, detail} "
|
|
110
110
|
"(not_found_on_page, ambiguous_date, struck_through, "
|
|
111
|
-
"
|
|
111
|
+
"printed_but_empty, row_not_extracted, ...); found by code, no model call")
|
|
112
112
|
alternatives: dict[str, list[dict[str, Any]]] = Field(
|
|
113
113
|
default_factory=dict, description="with alternatives=True (or a list of field paths): other values the "
|
|
114
114
|
"document gives for a field, by path, each {value, note, citations}")
|
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
"""Coverage: printed values the output did not take, found by code (no model call).
|
|
2
|
+
|
|
3
|
+
Two rules, built only from what the parser gives every document (form fields, table rows) and the output itself:
|
|
4
|
+
|
|
5
|
+
- ``printed_but_empty``: a field came back empty (null or []) while the document prints a label and value that no
|
|
6
|
+
output value used, and the label shares a word with that field's name, title or description;
|
|
7
|
+
- ``row_not_extracted``: a list took some rows of a table, but another item row of the same table was used by no
|
|
8
|
+
output value.
|
|
9
|
+
|
|
10
|
+
"Used" is decided per value, not per block: a printed value counts as used only if an output value matches it (as
|
|
11
|
+
text, number or date). Two fields printed in one box, or one value printed twice, are therefore told apart.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import re
|
|
17
|
+
from datetime import date
|
|
18
|
+
from typing import Any, Iterable, Optional
|
|
19
|
+
|
|
20
|
+
from ..textnorm import tokenize
|
|
21
|
+
from . import schema as S
|
|
22
|
+
|
|
23
|
+
_TAG = re.compile(r"<[^>]+>")
|
|
24
|
+
_ENTITY = re.compile(r"&(?:amp|lt|gt|quot|apos|nbsp|#3[49]|#160);", re.I)
|
|
25
|
+
_SKIP_TYPES = {"Header", "Footer", "Page Number", "Figure", "Signature", "Comment"}
|
|
26
|
+
_BASIC = {"the", "a", "an", "of", "to", "and", "or", "for", "in", "on", "at", "by", "is", "it", "its", "as",
|
|
27
|
+
"be", "this", "that", "with", "from", "e", "g", "eg", "if", "when", "any", "each", "all", "per", "not"}
|
|
28
|
+
_STOP = {"the", "a", "an", "of", "to", "and", "or", "for", "in", "on", "at", "by", "is", "it", "its", "as", "be",
|
|
29
|
+
"this", "that", "with", "from", "no", "number", "date", "value", "type", "name", "id", "code", "info",
|
|
30
|
+
"details", "detail", "total", "amount", "item", "items", "list", "field", "e", "g", "eg", "if", "when",
|
|
31
|
+
"any", "each", "all", "per", "not", "one", "who", "which", "what", "their", "they", "them", "has", "have"}
|
|
32
|
+
_MONTHS = {m: i + 1 for i, m in enumerate(["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct",
|
|
33
|
+
"nov", "dec"])}
|
|
34
|
+
_SUMMARY = re.compile(r"\b(sub-?\s?total|total|grand total|tax|vat|gst|balance|amount due|sum|carried forward|"
|
|
35
|
+
r"brought forward)\b", re.I)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _plain(s: str) -> str:
|
|
39
|
+
return " ".join(_ENTITY.sub(" ", _TAG.sub(" ", s or "")).replace("**", " ").split())
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _stem(w: str) -> str:
|
|
43
|
+
"""Singular of a plural word: parties -> party, taxes -> tax, lines -> line, contacts -> contact."""
|
|
44
|
+
w = w.lower()
|
|
45
|
+
if len(w) > 4 and w.endswith("ies"):
|
|
46
|
+
return w[:-3] + "y"
|
|
47
|
+
if len(w) > 4 and re.search(r"(s|x|z|ch|sh)es$", w):
|
|
48
|
+
return w[:-2]
|
|
49
|
+
if len(w) > 3 and w.endswith("s") and not w.endswith("ss"):
|
|
50
|
+
return w[:-1]
|
|
51
|
+
return w
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _words(s: str, stop: set = _STOP) -> set[str]:
|
|
55
|
+
s = re.sub(r"([a-z])([A-Z])", r"\1 \2", s or "").replace("_", " ")
|
|
56
|
+
return {_stem(t.norm) for t in tokenize(s) if len(t.norm) > 1 and not t.norm.isdigit()} - stop
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
# ------------------------------------------------------------------------------------------- printed pieces
|
|
60
|
+
|
|
61
|
+
class Piece:
|
|
62
|
+
"""A printed label and value (a form field, a pair in a two-column table) or a table item row."""
|
|
63
|
+
|
|
64
|
+
def __init__(self, label: str, value: str, page: int, block: str, kind: str, table: Optional[int] = None):
|
|
65
|
+
self.label, self.value, self.page, self.block, self.kind, self.table = label, value, page, block, kind, table
|
|
66
|
+
|
|
67
|
+
def __repr__(self) -> str:
|
|
68
|
+
return f"Piece({self.kind}, {self.label!r}: {self.value[:50]!r}, p{self.page})"
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _rows(html: str) -> list[list[tuple[str, bool]]]:
|
|
72
|
+
out = []
|
|
73
|
+
for row in re.findall(r"<tr\b[^>]*>(.*?)</tr>", html, re.I | re.S):
|
|
74
|
+
out.append([(_plain(c), tag.lower() == "th")
|
|
75
|
+
for tag, c in re.findall(r"<(t[dh])\b[^>]*>(.*?)</t[dh]>", row, re.I | re.S)])
|
|
76
|
+
return out
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def pieces(pages: Iterable[dict]) -> list[Piece]:
|
|
80
|
+
"""Every printed label/value and table item row of the parsed pages (headers, footers, figures skipped)."""
|
|
81
|
+
out: list[Piece] = []
|
|
82
|
+
tid = 0
|
|
83
|
+
for p in pages:
|
|
84
|
+
for r in p["regions"]:
|
|
85
|
+
t, c = r["type"], r["content"] or ""
|
|
86
|
+
if t in _SKIP_TYPES:
|
|
87
|
+
continue
|
|
88
|
+
if t == "Table" and "<tr" in c.lower():
|
|
89
|
+
tid += 1
|
|
90
|
+
rows = [x for x in _rows(c) if any(v for v, _ in x)]
|
|
91
|
+
if not rows:
|
|
92
|
+
continue
|
|
93
|
+
width = max(len(x) for x in rows)
|
|
94
|
+
head = [v for v, th in rows[0]] if all(th for _, th in rows[0]) or _header_like(rows) else None
|
|
95
|
+
body = rows[1:] if head else rows
|
|
96
|
+
if _pair_table(rows, width): # label | value (| label | value): a form drawn as a table
|
|
97
|
+
for x in rows:
|
|
98
|
+
for i in range(0, len(x) - 1, 2):
|
|
99
|
+
lab, val = x[i][0].rstrip(":").strip(), x[i + 1][0]
|
|
100
|
+
if lab and val and not x[i + 1][1] and not _HEADER_WORDS.issuperset(_words(lab, _BASIC)):
|
|
101
|
+
out.append(Piece(lab, val, p["number"], r["label"], "pair"))
|
|
102
|
+
continue
|
|
103
|
+
for x in body:
|
|
104
|
+
cells = [v for v, _ in x]
|
|
105
|
+
if len(cells) == 2 and cells[0] and cells[1] and not re.search(r"\d", cells[0]) \
|
|
106
|
+
and len(cells[0].split()) <= 4:
|
|
107
|
+
out.append(Piece(cells[0].rstrip(":"), cells[1], p["number"], r["label"], "pair"))
|
|
108
|
+
# "TOTAL | 46,000": a label and its value; it may also be an item ("Y.B.BAT | 46,000")
|
|
109
|
+
if len(x) < width or not cells[0] or any(_SUMMARY.search(v) for v in cells if v):
|
|
110
|
+
continue # a total under the items, a spanned label
|
|
111
|
+
if any(v.endswith(":") for v in cells) or not any(re.search(r"\d", v) for v in cells):
|
|
112
|
+
continue # labels with their values ("Terms: | 60 days"), or a header row: not an item
|
|
113
|
+
label = " ".join(head) if head else ""
|
|
114
|
+
out.append(Piece(label, " | ".join(cells), p["number"], r["label"], "row", tid))
|
|
115
|
+
continue
|
|
116
|
+
if t == "Key Value" or t == "Text":
|
|
117
|
+
for line in re.split(r"\n| / |<br\s*/?>", c):
|
|
118
|
+
for seg in re.split(r"\s{3,}|\t", _TAG.sub(" ", line)): # side-by-side columns of a form
|
|
119
|
+
seg = _plain(seg)
|
|
120
|
+
m = re.match(r"^([A-Za-z][^:]{0,40}):\s+(.+)$", seg)
|
|
121
|
+
if m and (t == "Key Value" or len(m.group(1).split()) <= 4):
|
|
122
|
+
out.append(Piece(m.group(1).strip(), m.group(2).strip(), p["number"], r["label"], "pair"))
|
|
123
|
+
return out
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
_HEADER_WORDS = {"label", "value", "field", "key", "item", "description", "detail", "name"}
|
|
127
|
+
_FORM_HEADER = {"label", "value", "field", "key", "detail", "information", "info"}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def _pair_table(rows: list, width: int) -> bool:
|
|
131
|
+
"""A table of labels and their values: 2 or 4 columns, the label cells short text (or ending in ":")."""
|
|
132
|
+
if width not in (2, 4):
|
|
133
|
+
return False
|
|
134
|
+
if rows and all(th for _, th in rows[0]) and len(rows[0]) == width:
|
|
135
|
+
names = set().union(*(_words(v, _BASIC) for v, _ in rows[0]))
|
|
136
|
+
if names - _FORM_HEADER:
|
|
137
|
+
return False # a header naming columns ("Item | Amount"): an item table, not a form
|
|
138
|
+
body = [x for x in rows if not all(th for _, th in x) and len(x) == width] # a narrower row is a heading
|
|
139
|
+
if len(body) < 2:
|
|
140
|
+
return False
|
|
141
|
+
labels = [x[i][0] for x in body for i in range(0, len(x) - 1, 2) if x[i][0] or x[i + 1][0]]
|
|
142
|
+
if not labels:
|
|
143
|
+
return False
|
|
144
|
+
short = [v for v in labels if v and len(v.split()) <= 5 and not re.search(r"\d", v)]
|
|
145
|
+
colon = [v for v in labels if v.endswith(":")]
|
|
146
|
+
return len(short) >= 0.8 * len(labels) and (width == 2 or len(colon) >= 0.5 * len(labels) or
|
|
147
|
+
len(short) == len(labels))
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def _header_like(rows: list) -> bool:
|
|
151
|
+
"""A first row of labels over rows of values (no amount or digit in it, more digits below)."""
|
|
152
|
+
if len(rows) < 2:
|
|
153
|
+
return False
|
|
154
|
+
first = [v for v, _ in rows[0]]
|
|
155
|
+
return not any(re.search(r"\d", v) for v in first) and any(re.search(r"\d", v) for x in rows[1:] for v, _ in x)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
# ------------------------------------------------------------------------------------------------ matching
|
|
159
|
+
|
|
160
|
+
_NUM = re.compile(r"\d{1,3}(?:[ ,.'\u00a0\u202f]\d{3})+(?:[.,]\d{1,2})?(?!\d)|\d+(?:[.,]\d+)?")
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def _numbers(s: str) -> set[float]:
|
|
164
|
+
"""Numbers as printed in any common form: 1,370.53, 1 370.53, 1.370,53, 1'370.53, 370.53."""
|
|
165
|
+
out = set()
|
|
166
|
+
for m in _NUM.finditer(s or ""):
|
|
167
|
+
t = m.group(0)
|
|
168
|
+
seps = re.findall(r"[ ,.'\u00a0\u202f]", t)
|
|
169
|
+
dec = ""
|
|
170
|
+
if seps and re.search(r"[.,]\d{1,2}$", t) and (len(seps) > 1 or len(t.split(seps[-1])[-1]) != 3):
|
|
171
|
+
dec = t[-3:] if t[-3] in ".," else t[-2:]
|
|
172
|
+
t = t[: -len(dec)]
|
|
173
|
+
dec = "." + dec[1:]
|
|
174
|
+
t = re.sub(r"[ ,.'\u00a0\u202f]", "", t) if len(seps) > (1 if dec else 0) or (seps and not dec and
|
|
175
|
+
len(t.split(seps[0])[-1]) == 3) else t.replace(",", ".")
|
|
176
|
+
try:
|
|
177
|
+
out.add(round(float(t + dec), 4))
|
|
178
|
+
except ValueError:
|
|
179
|
+
pass
|
|
180
|
+
return out
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def _dates(s: str) -> set[date]:
|
|
184
|
+
out = set()
|
|
185
|
+
for y, mo, d in re.findall(r"\b(\d{4})-(\d{1,2})-(\d{1,2})\b", s):
|
|
186
|
+
try:
|
|
187
|
+
out.add(date(int(y), int(mo), int(d)))
|
|
188
|
+
except ValueError:
|
|
189
|
+
pass
|
|
190
|
+
for a, b, c in re.findall(r"\b(\d{1,4})[/.](\d{1,2})[/.](\d{2,4})\b", s):
|
|
191
|
+
a, b, c = int(a), int(b), int(c)
|
|
192
|
+
for y, mo, d in ((a, b, c), (c, b, a), (c, a, b)) if a > 31 else ((c, b, a), (c, a, b)):
|
|
193
|
+
y = y + 2000 if y < 100 else y
|
|
194
|
+
try:
|
|
195
|
+
out.add(date(y, mo, d))
|
|
196
|
+
except ValueError:
|
|
197
|
+
pass
|
|
198
|
+
for mname, d, y in re.findall(r"\b([A-Za-z]{3,9})\.?\s+(\d{1,2}),?\s+(\d{4})\b", s):
|
|
199
|
+
mo = _MONTHS.get(mname[:3].lower())
|
|
200
|
+
if mo:
|
|
201
|
+
try:
|
|
202
|
+
out.add(date(int(y), mo, int(d)))
|
|
203
|
+
except ValueError:
|
|
204
|
+
pass
|
|
205
|
+
for d, mname, y in re.findall(r"\b(\d{1,2})\s+([A-Za-z]{3,9})\.?,?\s+(\d{4})\b", s):
|
|
206
|
+
mo = _MONTHS.get(mname[:3].lower())
|
|
207
|
+
if mo:
|
|
208
|
+
try:
|
|
209
|
+
out.add(date(int(y), mo, int(d)))
|
|
210
|
+
except ValueError:
|
|
211
|
+
pass
|
|
212
|
+
return out
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
class _Used:
|
|
216
|
+
"""The output's values, ready to test whether a printed value was taken."""
|
|
217
|
+
|
|
218
|
+
def __init__(self, value: Any, schema: Any):
|
|
219
|
+
self.tokens: list[list[str]] = []
|
|
220
|
+
self.nums: set[float] = set()
|
|
221
|
+
self.dates: set[date] = set()
|
|
222
|
+
for _, v, _s in S.iter_leaves(value, schema):
|
|
223
|
+
if v is None or isinstance(v, bool) or v == "":
|
|
224
|
+
continue
|
|
225
|
+
if isinstance(v, (int, float)):
|
|
226
|
+
self.nums.add(round(float(v), 4))
|
|
227
|
+
continue
|
|
228
|
+
s = str(v)
|
|
229
|
+
self.dates |= _dates(s)
|
|
230
|
+
if re.fullmatch(r"[^\w]*[A-Za-z.]{0,4}\s?[-(]?[\d ,.'\u00a0\u202f]+\)?[^\w]*", s.strip()):
|
|
231
|
+
self.nums |= {n for n in _numbers(s)} # a number written as text: "10,091", "Rp 46.000"
|
|
232
|
+
toks = [t.norm for t in tokenize(s)]
|
|
233
|
+
if toks:
|
|
234
|
+
self.tokens.append(toks)
|
|
235
|
+
|
|
236
|
+
def took(self, printed: str) -> bool:
|
|
237
|
+
"""An output value took this printed text: the same date, a distinctive number (10 or more, or with
|
|
238
|
+
decimals), or output words covering at least 40% of its words. A short common value ("USD", "1") alone
|
|
239
|
+
does not take a longer text."""
|
|
240
|
+
toks = [t.norm for t in tokenize(printed)]
|
|
241
|
+
if not toks:
|
|
242
|
+
return True # nothing to take
|
|
243
|
+
if _dates(printed) & self.dates:
|
|
244
|
+
return True
|
|
245
|
+
nums = {n for n in _numbers(printed) if abs(n) >= 10 or n != int(n)}
|
|
246
|
+
if nums & self.nums:
|
|
247
|
+
return True
|
|
248
|
+
covered = [False] * len(toks)
|
|
249
|
+
for t in self.tokens:
|
|
250
|
+
if len(t) == 1 and (t[0].isdigit() or len(t[0]) < 3):
|
|
251
|
+
continue
|
|
252
|
+
n = len(t)
|
|
253
|
+
for i in range(len(toks) - n + 1):
|
|
254
|
+
if toks[i:i + n] == t:
|
|
255
|
+
for j in range(i, i + n):
|
|
256
|
+
covered[j] = True
|
|
257
|
+
words = [i for i, w in enumerate(toks) if not w.isdigit()] or list(range(len(toks)))
|
|
258
|
+
return sum(covered[i] for i in words) >= max(1.0, 0.4 * len(words))
|
|
259
|
+
|
|
260
|
+
def took_row(self, cells: list[str]) -> bool:
|
|
261
|
+
"""A table row is taken when what identifies it was: its first cell, a text cell of two words or more,
|
|
262
|
+
a distinctive number (10 or more, or with decimals), or any two cells."""
|
|
263
|
+
cells = [c for c in cells if c.strip()]
|
|
264
|
+
if not cells:
|
|
265
|
+
return True
|
|
266
|
+
hits = 0
|
|
267
|
+
for i, c in enumerate(cells):
|
|
268
|
+
if not self.took(c):
|
|
269
|
+
continue
|
|
270
|
+
hits += 1
|
|
271
|
+
words = [w for w in tokenize(c) if not w.norm.isdigit()]
|
|
272
|
+
if i == 0 or len(words) >= 2 or {n for n in _numbers(c) if abs(n) >= 10 or n != int(n)}:
|
|
273
|
+
return True
|
|
274
|
+
return hits >= 2
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
# ---------------------------------------------------------------------------------------------- the checks
|
|
278
|
+
|
|
279
|
+
def _field_words(schema: Any) -> dict[str, set[str]]:
|
|
280
|
+
"""Normalised field path ("customer.contacts") -> words of its name, title and description, for every field
|
|
281
|
+
and list in the schema."""
|
|
282
|
+
out: dict[str, set[str]] = {}
|
|
283
|
+
|
|
284
|
+
def go(node: Any, path: tuple) -> None:
|
|
285
|
+
if not isinstance(node, dict):
|
|
286
|
+
return
|
|
287
|
+
n = S.branch_for(node, {}) if (node.get("anyOf") or node.get("oneOf")) else node
|
|
288
|
+
if not isinstance(n, dict):
|
|
289
|
+
return
|
|
290
|
+
if path:
|
|
291
|
+
words = _words(path[-1], _BASIC) | _words(str(n.get("title") or node.get("title") or ""), _BASIC)
|
|
292
|
+
words |= _words(str(n.get("description") or node.get("description") or ""))
|
|
293
|
+
out[".".join(path)] = out.get(".".join(path), set()) | words
|
|
294
|
+
if S.is_object(n):
|
|
295
|
+
for k, v in (n.get("properties") or {}).items():
|
|
296
|
+
go(v, path + (k,))
|
|
297
|
+
elif S.is_array(n):
|
|
298
|
+
items = S.branch_for(n.get("items") or {}, {})
|
|
299
|
+
if path and isinstance(items, dict) and S.is_object(items): # a list is also named by its items' fields
|
|
300
|
+
for k, v in (items.get("properties") or {}).items():
|
|
301
|
+
out[".".join(path)] |= _words(k, _BASIC) | _words(str((v or {}).get("title") or ""), _BASIC)
|
|
302
|
+
go(n.get("items") or {}, path)
|
|
303
|
+
|
|
304
|
+
go(schema, ())
|
|
305
|
+
return out
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
def _output_lists(value: Any, schema: Any) -> list[tuple[str, "_Used"]]:
|
|
309
|
+
"""(path, its values) for every list of objects in the output: to name the list a table's rows belong to."""
|
|
310
|
+
out: list = []
|
|
311
|
+
|
|
312
|
+
def go(v: Any, s: Any, path: tuple) -> None:
|
|
313
|
+
s = S.branch_for(s, v) if isinstance(s, dict) else s
|
|
314
|
+
if isinstance(v, dict) and isinstance(s, dict) and S.is_object(s):
|
|
315
|
+
for k, x in v.items():
|
|
316
|
+
go(x, (s.get("properties") or {}).get(k, {}), path + (k,))
|
|
317
|
+
elif isinstance(v, list) and isinstance(s, dict) and S.is_array(s) and v and all(isinstance(i, dict) for i in v):
|
|
318
|
+
out.append((".".join(path), _Used(v, s)))
|
|
319
|
+
|
|
320
|
+
go(value, schema, ())
|
|
321
|
+
return out
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
def _list_paths(schema: Any) -> set[str]:
|
|
325
|
+
out: set = set()
|
|
326
|
+
|
|
327
|
+
def go(node: Any, path: tuple) -> None:
|
|
328
|
+
n = S.branch_for(node, {}) if isinstance(node, dict) and (node.get("anyOf") or node.get("oneOf")) else node
|
|
329
|
+
if not isinstance(n, dict):
|
|
330
|
+
return
|
|
331
|
+
if S.is_object(n):
|
|
332
|
+
for k, v in (n.get("properties") or {}).items():
|
|
333
|
+
go(v, path + (k,))
|
|
334
|
+
elif S.is_array(n):
|
|
335
|
+
out.add(".".join(path))
|
|
336
|
+
go(n.get("items") or {}, path)
|
|
337
|
+
|
|
338
|
+
go(schema, ())
|
|
339
|
+
return out
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
def _empty_fields(value: Any, schema: Any) -> list[str]:
|
|
343
|
+
"""Normalised paths of fields that came back null or [] (inside a list item: per item, path without index)."""
|
|
344
|
+
out: list[str] = []
|
|
345
|
+
|
|
346
|
+
def go(v: Any, s: Any, path: tuple) -> None:
|
|
347
|
+
s = S.branch_for(s, v) if isinstance(s, dict) else s
|
|
348
|
+
if not isinstance(s, dict):
|
|
349
|
+
return
|
|
350
|
+
if S.is_object(s):
|
|
351
|
+
if not isinstance(v, dict):
|
|
352
|
+
if v is None and path:
|
|
353
|
+
out.append(".".join(path))
|
|
354
|
+
return
|
|
355
|
+
for k, sub in (s.get("properties") or {}).items():
|
|
356
|
+
go(v.get(k), sub, path + (k,))
|
|
357
|
+
elif S.is_array(s):
|
|
358
|
+
if not v:
|
|
359
|
+
out.append(".".join(path))
|
|
360
|
+
return
|
|
361
|
+
for item in v:
|
|
362
|
+
go(item, s.get("items") or {}, path)
|
|
363
|
+
elif v is None or v == "":
|
|
364
|
+
out.append(".".join(path))
|
|
365
|
+
|
|
366
|
+
go(value, schema, ())
|
|
367
|
+
return list(dict.fromkeys(out))
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
def _shape(v: str) -> Optional[str]:
|
|
371
|
+
"""The kind of value a printed text is, when its form says so: "email", "phone", "url"."""
|
|
372
|
+
if re.search(r"[\w.+-]+@[\w-]+\.[\w.]+", v):
|
|
373
|
+
return "email"
|
|
374
|
+
if re.search(r"https?://|www\.", v):
|
|
375
|
+
return "url"
|
|
376
|
+
if _dates(v):
|
|
377
|
+
return "date"
|
|
378
|
+
if re.fullmatch(r"[+()\d\s.-]{7,}", v.strip()) and len(re.sub(r"\D", "", v)) >= 7:
|
|
379
|
+
return "phone"
|
|
380
|
+
return None
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
def check(value: Any, schema: Any, pages: list[dict]) -> list[dict]:
|
|
384
|
+
"""[{"field", "flag", "detail"}]: printed values the output did not take (see the module docstring)."""
|
|
385
|
+
found = pieces(pages)
|
|
386
|
+
used = _Used(value, schema)
|
|
387
|
+
taken = {id(p): (used.took_row(p.value.split(" | ")) if p.kind == "row" else used.took(p.value)) for p in found}
|
|
388
|
+
free = [p for p in found if not taken[id(p)]]
|
|
389
|
+
words = _field_words(schema)
|
|
390
|
+
out: list[dict] = []
|
|
391
|
+
|
|
392
|
+
# A. printed_but_empty: the most specific empty field whose words the free label shares
|
|
393
|
+
empty = _empty_fields(value, schema)
|
|
394
|
+
lists_ = _list_paths(schema)
|
|
395
|
+
flagged_tables: set = set()
|
|
396
|
+
for p in free:
|
|
397
|
+
if p.kind == "row" and (p.table in flagged_tables or not p.label):
|
|
398
|
+
continue
|
|
399
|
+
lw = _words(p.label, _BASIC if p.kind == "row" else _STOP)
|
|
400
|
+
shape = _shape(p.value)
|
|
401
|
+
best, score = None, 0
|
|
402
|
+
for f in empty:
|
|
403
|
+
if p.kind == "row" and f not in lists_:
|
|
404
|
+
continue # a table's rows are the items of a list, never one single value
|
|
405
|
+
fw = words.get(f, set())
|
|
406
|
+
own = _words(f.rsplit(".", 1)[-1], _BASIC)
|
|
407
|
+
hit = len(lw & fw) + len(_words(p.label, _BASIC) & own) # the field's own name counts twice, and
|
|
408
|
+
# there a common word ("Total", "Date") counts: the field is empty and is named exactly that
|
|
409
|
+
if lw and not lw & (fw | own) and not (shape in ("email", "url", "phone") and shape in own):
|
|
410
|
+
continue # "Credit Date" is not the due date: the label's own words name something else
|
|
411
|
+
if p.kind == "pair" and shape and shape in own:
|
|
412
|
+
hit += 2 # an email printed, an email field empty: matched by the value's shape
|
|
413
|
+
if f in lists_ and p.kind == "pair" and hit < 2:
|
|
414
|
+
continue # a list is named by all its items' fields: one shared word is not enough
|
|
415
|
+
if hit > score:
|
|
416
|
+
best, score = f, hit
|
|
417
|
+
if best and p.kind == "row":
|
|
418
|
+
need = 2 # a table header shares at least two words with the list, or it is not that list's table
|
|
419
|
+
if score >= need:
|
|
420
|
+
flagged_tables.add(p.table)
|
|
421
|
+
out.append({"field": best, "flag": "printed_but_empty",
|
|
422
|
+
"detail": f'a table with "{p.label[:60]}" (page {p.page}) has rows such as '
|
|
423
|
+
f'"{p.value[:60]}", and {best} is empty'})
|
|
424
|
+
elif best:
|
|
425
|
+
out.append({"field": best, "flag": "printed_but_empty",
|
|
426
|
+
"detail": f'"{p.label}: {p.value[:80]}" is printed on page {p.page}, and {best} is empty'})
|
|
427
|
+
|
|
428
|
+
# B. row_not_extracted: a table some of whose item rows were taken, and another row not
|
|
429
|
+
tables: dict[int, list[Piece]] = {}
|
|
430
|
+
for p in found:
|
|
431
|
+
if p.kind == "row" and p.table is not None:
|
|
432
|
+
tables.setdefault(p.table, []).append(p)
|
|
433
|
+
lists_out = _output_lists(value, schema)
|
|
434
|
+
for rows in tables.values():
|
|
435
|
+
took = [r for r in rows if taken[id(r)]]
|
|
436
|
+
if not took or len(took) == len(rows) or (len(took) < 2 and len(rows) > 3):
|
|
437
|
+
continue # one row matching by chance in a long table says nothing about that table
|
|
438
|
+
owner = max(lists_out, key=lambda kv: sum(kv[1].took_row(r.value.split(" | ")) for r in took),
|
|
439
|
+
default=(None, None))[0]
|
|
440
|
+
for r in rows:
|
|
441
|
+
if r not in took:
|
|
442
|
+
out.append({"field": owner, "flag": "row_not_extracted",
|
|
443
|
+
"detail": f'table row "{r.value[:80]}" (page {r.page}) is not in the output, though '
|
|
444
|
+
f"{len(took)} other rows of its table are"})
|
|
445
|
+
return out
|
|
@@ -9,7 +9,10 @@ Each check names a field and a reason a reader should look at it:
|
|
|
9
9
|
- ``segments_disagree``: two parts of a long document gave different values;
|
|
10
10
|
- ``filled_because_required``: a number or text field filled because ``fill_required`` asks for it, and not
|
|
11
11
|
printed in the document as returned: it may be a guess;
|
|
12
|
-
- ``
|
|
12
|
+
- ``printed_but_empty``: a field is empty, but the document prints a value for it that nothing in the output took
|
|
13
|
+
(``coverage``);
|
|
14
|
+
- ``row_not_extracted``: a list took some rows of a table, and another item row of it is in no output value
|
|
15
|
+
(``coverage``; replaces ``list_may_be_incomplete``);
|
|
13
16
|
- ``unreadable``: the model's reply for the field could not be read.
|
|
14
17
|
|
|
15
18
|
Nothing here changes a value.
|
|
@@ -275,25 +278,10 @@ def review(value: Any, schema: Any, cites: dict, ex: Any, *, conflicts: list, un
|
|
|
275
278
|
for f in sorted(unreadable):
|
|
276
279
|
add(f, "unreadable", "the model's reply for this field could not be read; it may be in the document")
|
|
277
280
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
if len(p_) > len(path) and p_[:len(path)] == path:
|
|
285
|
-
for c in cs:
|
|
286
|
-
blk = c.get("parentBlock") or {}
|
|
287
|
-
if blk.get("type") == "Table" and blk.get("content"):
|
|
288
|
-
tables[blk["content"]] = True
|
|
289
|
-
rows = sum(amount_rows(t) for t in tables)
|
|
290
|
-
if rows >= 2 and len(v) < rows:
|
|
291
|
-
add(S.path_str(path), "list_may_be_incomplete",
|
|
292
|
-
f"{len(v)} items, but the table they come from has {rows} rows with an amount")
|
|
293
|
-
return # lists inside list items cite the same table: not checked again
|
|
294
|
-
if isinstance(v, dict) and S.is_object(s):
|
|
295
|
-
for k, x in v.items():
|
|
296
|
-
lists(x, s["properties"].get(k, {}), path + (k,))
|
|
297
|
-
|
|
298
|
-
lists(value, schema, ())
|
|
281
|
+
from . import coverage # printed values the output did not take (code only)
|
|
282
|
+
pages_ = [{"number": p.number, "regions": [{"label": r.label, "type": r.region.type.value,
|
|
283
|
+
"content": r.region.content} for r in p.regions]}
|
|
284
|
+
for p in (getattr(ex, "pages", None) or [])]
|
|
285
|
+
for f in coverage.check(value, schema, pages_):
|
|
286
|
+
add(f["field"] or "", f["flag"], f["detail"])
|
|
299
287
|
return out
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""Coverage flags: printed values the output did not take (code only, generic rules)."""
|
|
2
|
+
from readanydoc.tasks import coverage as C
|
|
3
|
+
|
|
4
|
+
SCHEMA = {"type": "object", "properties": {
|
|
5
|
+
"customer": {"type": "object", "properties": {
|
|
6
|
+
"name": {"type": "string"}, "email": {"type": ["string", "null"]},
|
|
7
|
+
"contacts": {"type": "array", "items": {"type": "object", "properties": {
|
|
8
|
+
"first_name": {"type": "string"}, "last_name": {"type": "string"}}}}}},
|
|
9
|
+
"invoice_date": {"type": ["string", "null"]},
|
|
10
|
+
"items": {"type": "array", "items": {"type": "object", "properties": {
|
|
11
|
+
"description": {"type": "string"}, "amount": {"type": "number"}}}}}}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def page(*regions):
|
|
15
|
+
return [{"number": 1, "regions": [{"label": f"r{i}", "type": t, "content": c} for i, (t, c) in enumerate(regions)]}]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
TABLE = ("<table><tr><th>Description</th><th>Qty</th><th>Amount</th></tr>"
|
|
19
|
+
"<tr><td>Widget large</td><td>2</td><td>40.00</td></tr>"
|
|
20
|
+
"<tr><td>Gadget small</td><td>1</td><td>15.50</td></tr>"
|
|
21
|
+
"<tr><td>Spanner set</td><td>3</td><td>27.25</td></tr>"
|
|
22
|
+
"<tr><td colspan='2'>Total</td><td>82.75</td></tr></table>")
|
|
23
|
+
PAGES = page(("Key Value", "Customer: Acme Ltd"), ("Key Value", "Billing Contact: Dana Ruiz, Controller"),
|
|
24
|
+
("Key Value", "Email: ap@acme.test"), ("Key Value", "Date: 03/02/2026"), ("Table", TABLE),
|
|
25
|
+
("Footer", "Contact: footer@acme.test"))
|
|
26
|
+
FULL = {"customer": {"name": "Acme Ltd", "email": "ap@acme.test",
|
|
27
|
+
"contacts": [{"first_name": "Dana", "last_name": "Ruiz"}]},
|
|
28
|
+
"invoice_date": "2026-02-03",
|
|
29
|
+
"items": [{"description": "Widget large", "amount": 40.0}, {"description": "Gadget small", "amount": 15.5},
|
|
30
|
+
{"description": "Spanner set", "amount": 27.25}]}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def test_complete_output_has_no_flags():
|
|
34
|
+
assert C.check(FULL, SCHEMA, PAGES) == []
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def test_dropped_contact_is_flagged_on_its_field():
|
|
38
|
+
v = {**FULL, "customer": {**FULL["customer"], "contacts": []}}
|
|
39
|
+
f = C.check(v, SCHEMA, PAGES)
|
|
40
|
+
assert [x["field"] for x in f] == ["customer.contacts"] and "Dana Ruiz" in f[0]["detail"]
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def test_shared_email_does_not_hide_a_dropped_contact():
|
|
44
|
+
pages = page(("Key Value", "Billing Contact: Dana Ruiz"), ("Key Value", "Billing Email: ap@acme.test"))
|
|
45
|
+
v = {"customer": {"name": "Acme", "email": "ap@acme.test", "contacts": []}}
|
|
46
|
+
assert [x["field"] for x in C.check(v, SCHEMA, pages)] == ["customer.contacts"]
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_value_shape_matches_an_empty_field():
|
|
50
|
+
v = {**FULL, "customer": {**FULL["customer"], "email": None}}
|
|
51
|
+
assert [x["field"] for x in C.check(v, SCHEMA, PAGES)] == ["customer.email"]
|
|
52
|
+
v = {**FULL, "invoice_date": None}
|
|
53
|
+
assert [x["field"] for x in C.check(v, SCHEMA, PAGES)] == ["invoice_date"]
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def test_missing_rows_and_emptied_list():
|
|
57
|
+
v = {**FULL, "items": FULL["items"][:1] + FULL["items"][2:]}
|
|
58
|
+
f = C.check(v, SCHEMA, PAGES)
|
|
59
|
+
assert [x["flag"] for x in f] == ["row_not_extracted"] and "Gadget small" in f[0]["detail"]
|
|
60
|
+
f = C.check({**FULL, "items": []}, SCHEMA, PAGES)
|
|
61
|
+
assert [(x["flag"], x["field"]) for x in f] == [("printed_but_empty", "items")]
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def test_form_drawn_as_a_table_is_read_as_pairs():
|
|
65
|
+
t = ("<table><tr><th>Label</th><th>Value</th></tr><tr><td>Customer</td><td>Acme Ltd</td></tr>"
|
|
66
|
+
"<tr><td>Billing Contact</td><td>Dana Ruiz</td></tr></table>")
|
|
67
|
+
assert [p.kind for p in C.pieces(page(("Table", t)))] == ["pair", "pair"]
|
|
68
|
+
v = {"customer": {"name": "Acme Ltd", "contacts": []}}
|
|
69
|
+
assert [x["field"] for x in C.check(v, SCHEMA, page(("Table", t)))] == ["customer.contacts"]
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def test_unrelated_printed_values_are_not_flagged():
|
|
73
|
+
pages = page(("Key Value", "PO Number: 4471"), ("Key Value", "Signed by: Lee Park"))
|
|
74
|
+
assert C.check({"customer": {"name": "Acme", "contacts": [{"first_name": "Dana"}]}}, SCHEMA, pages) == []
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def test_stem_and_dates():
|
|
78
|
+
assert [C._stem(w) for w in ("lines", "parties", "taxes", "contacts", "address")] == \
|
|
79
|
+
["line", "party", "tax", "contact", "address"]
|
|
80
|
+
from datetime import date
|
|
81
|
+
assert date(2026, 2, 3) in C._dates("03/02/2026") and date(2026, 3, 13) in C._dates("2026/03/13")
|