readanydoc 0.4.0__tar.gz → 0.4.2__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.
Files changed (286) hide show
  1. {readanydoc-0.4.0 → readanydoc-0.4.2}/CHANGELOG.md +23 -0
  2. {readanydoc-0.4.0 → readanydoc-0.4.2}/PKG-INFO +1 -1
  3. {readanydoc-0.4.0 → readanydoc-0.4.2}/plugins/readanydoc/.claude-plugin/plugin.json +1 -1
  4. {readanydoc-0.4.0 → readanydoc-0.4.2}/plugins/readanydoc/.mcp.json +1 -1
  5. {readanydoc-0.4.0 → readanydoc-0.4.2}/pyproject.toml +1 -1
  6. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/__init__.py +1 -1
  7. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/bench/catalog.py +33 -11
  8. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/tasks/coded.py +7 -4
  9. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/tasks/extract.py +46 -5
  10. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/tasks/field_report.py +13 -2
  11. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/tasks/reply_schema.py +52 -14
  12. readanydoc-0.4.2/tests/tasks/test_required_choices.py +53 -0
  13. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/test_bench_suite.py +13 -0
  14. {readanydoc-0.4.0 → readanydoc-0.4.2}/.gitignore +0 -0
  15. {readanydoc-0.4.0 → readanydoc-0.4.2}/LICENSE +0 -0
  16. {readanydoc-0.4.0 → readanydoc-0.4.2}/README.md +0 -0
  17. {readanydoc-0.4.0 → readanydoc-0.4.2}/docs/research/README.md +0 -0
  18. {readanydoc-0.4.0 → readanydoc-0.4.2}/examples/showcase/README.md +0 -0
  19. {readanydoc-0.4.0 → readanydoc-0.4.2}/plugins/readanydoc/.claude-plugin/icon.png +0 -0
  20. {readanydoc-0.4.0 → readanydoc-0.4.2}/plugins/readanydoc/README.md +0 -0
  21. {readanydoc-0.4.0 → readanydoc-0.4.2}/plugins/readanydoc/skills/read-documents/SKILL.md +0 -0
  22. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/api/__init__.py +0 -0
  23. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/api/__main__.py +0 -0
  24. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/api/app.py +0 -0
  25. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/api/config.py +0 -0
  26. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/api/contracts.py +0 -0
  27. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/api/errors.py +0 -0
  28. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/api/inputs.py +0 -0
  29. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/api/schemas.py +0 -0
  30. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/api/service.py +0 -0
  31. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/api/webhooks.py +0 -0
  32. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/api/worker.py +0 -0
  33. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/bench/__init__.py +0 -0
  34. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/bench/fetch.py +0 -0
  35. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/bench/grade.py +0 -0
  36. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/bench/report.py +0 -0
  37. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/bench/runner.py +0 -0
  38. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/bench/systems.py +0 -0
  39. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/cli.py +0 -0
  40. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/cvsafe.py +0 -0
  41. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/data/model_limits.json +0 -0
  42. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/intake/__init__.py +0 -0
  43. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/intake/common.py +0 -0
  44. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/intake/docx_reader.py +0 -0
  45. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/intake/errors.py +0 -0
  46. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/intake/heic.py +0 -0
  47. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/intake/legacy.py +0 -0
  48. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/intake/msg.py +0 -0
  49. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/intake/pdf.py +0 -0
  50. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/intake/pptx_reader.py +0 -0
  51. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/intake/prepare.py +0 -0
  52. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/intake/sheets.py +0 -0
  53. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/intake/sniff.py +0 -0
  54. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/intake/text.py +0 -0
  55. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/integrations/__init__.py +0 -0
  56. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/integrations/langchain.py +0 -0
  57. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/integrations/llamaindex.py +0 -0
  58. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/layout/__init__.py +0 -0
  59. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/layout/base.py +0 -0
  60. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/layout/cached.py +0 -0
  61. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/layout/claude.py +0 -0
  62. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/layout/onnx.py +0 -0
  63. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/library.py +0 -0
  64. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/localmodels.py +0 -0
  65. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/mcp_server.py +0 -0
  66. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/model/__init__.py +0 -0
  67. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/model/document.py +0 -0
  68. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/model_limits.py +0 -0
  69. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/modelspec.py +0 -0
  70. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/paths.py +0 -0
  71. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/__init__.py +0 -0
  72. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/assemble.py +0 -0
  73. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/assembly/__init__.py +0 -0
  74. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/assembly/annotations.py +0 -0
  75. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/assembly/furniture.py +0 -0
  76. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/assembly/headings.py +0 -0
  77. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/assembly/paragraphs.py +0 -0
  78. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/assembly/tables.py +0 -0
  79. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/base.py +0 -0
  80. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/checks/__init__.py +0 -0
  81. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/checks/common.py +0 -0
  82. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/checks/complete.py +0 -0
  83. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/checks/flags.py +0 -0
  84. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/checks/gridrepair.py +0 -0
  85. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/checks/htmlgrid.py +0 -0
  86. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/checks/numbers.py +0 -0
  87. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/checks/reread.py +0 -0
  88. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/common.py +0 -0
  89. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/figures/__init__.py +0 -0
  90. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/figures/layout_pictures.py +0 -0
  91. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/figures/locate.py +0 -0
  92. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/forms/__init__.py +0 -0
  93. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/forms/acroform.py +0 -0
  94. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/forms/checkbox.py +0 -0
  95. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/forms/fillable.py +0 -0
  96. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/forms/grid.py +0 -0
  97. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/forms/lines.py +0 -0
  98. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/forms/locate.py +0 -0
  99. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/forms/region.py +0 -0
  100. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/forms/rules.py +0 -0
  101. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/ground.py +0 -0
  102. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/grounding/__init__.py +0 -0
  103. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/grounding/align.py +0 -0
  104. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/grounding/confidence.py +0 -0
  105. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/grounding/ocr.py +0 -0
  106. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/grounding/sources.py +0 -0
  107. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/grounding/tables.py +0 -0
  108. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/grounding/tokens.py +0 -0
  109. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/intake.py +0 -0
  110. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/layout.py +0 -0
  111. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/mdblocks.py +0 -0
  112. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/read.py +0 -0
  113. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/reading/__init__.py +0 -0
  114. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/reading/budget.py +0 -0
  115. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/reading/effort_route.py +0 -0
  116. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/reading/escalate.py +0 -0
  117. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/reading/evidence.py +0 -0
  118. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/reading/form_prefetch.py +0 -0
  119. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/reading/formulas.py +0 -0
  120. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/reading/fusion.py +0 -0
  121. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/reading/handwriting.py +0 -0
  122. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/reading/robust.py +0 -0
  123. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/reading/select.py +0 -0
  124. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/reading/strips.py +0 -0
  125. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/reading/tables.py +0 -0
  126. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/reading/zoom.py +0 -0
  127. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/reading/zoom_gate.py +0 -0
  128. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/reading/zoom_regions.py +0 -0
  129. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/reading/zoom_schedule.py +0 -0
  130. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/regions/__init__.py +0 -0
  131. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/regions/assemble.py +0 -0
  132. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/regions/complete.py +0 -0
  133. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/regions/crops.py +0 -0
  134. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/regions/fields.py +0 -0
  135. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/regions/formevidence.py +0 -0
  136. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/regions/forms.py +0 -0
  137. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/regions/furniture.py +0 -0
  138. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/regions/match.py +0 -0
  139. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/regions/structure.py +0 -0
  140. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/regions/tables.py +0 -0
  141. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/request.py +0 -0
  142. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/shape.py +0 -0
  143. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/shaping/__init__.py +0 -0
  144. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/shaping/agentic.py +0 -0
  145. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/shaping/chunking.py +0 -0
  146. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/shaping/embed.py +0 -0
  147. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/shaping/merge.py +0 -0
  148. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/shaping/options.py +0 -0
  149. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/shaping/page_range.py +0 -0
  150. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/shaping/response.py +0 -0
  151. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/shaping/searchable.py +0 -0
  152. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/shaping/summarize.py +0 -0
  153. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/shaping/tables.py +0 -0
  154. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/tables/__init__.py +0 -0
  155. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/tables/evidence.py +0 -0
  156. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/tables/hygiene.py +0 -0
  157. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/tables/prefetch.py +0 -0
  158. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/tables/reread.py +0 -0
  159. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/triage.py +0 -0
  160. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/typing/__init__.py +0 -0
  161. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/typing/layout.py +0 -0
  162. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/typing/markup.py +0 -0
  163. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/pipeline/verify.py +0 -0
  164. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/profiles.py +0 -0
  165. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/readers/__init__.py +0 -0
  166. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/readers/anthropic_api.py +0 -0
  167. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/readers/anthropic_batch.py +0 -0
  168. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/readers/base.py +0 -0
  169. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/readers/batch_mode.py +0 -0
  170. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/readers/cached.py +0 -0
  171. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/readers/claude_cli.py +0 -0
  172. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/readers/crop_cache.py +0 -0
  173. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/readers/live_cache.py +0 -0
  174. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/readers/ocr_words.py +0 -0
  175. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/readers/openai_compatible.py +0 -0
  176. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/readers/prompts.py +0 -0
  177. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/readers/sizing.py +0 -0
  178. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/readers/usage.py +0 -0
  179. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/serialize/__init__.py +0 -0
  180. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/serialize/citations.py +0 -0
  181. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/serialize/reducto.py +0 -0
  182. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/star.py +0 -0
  183. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/store/__init__.py +0 -0
  184. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/store/cleanup.py +0 -0
  185. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/store/db.py +0 -0
  186. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/store/files.py +0 -0
  187. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/store/jobs.py +0 -0
  188. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/tasks/__init__.py +0 -0
  189. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/tasks/classify.py +0 -0
  190. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/tasks/common.py +0 -0
  191. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/tasks/detect.py +0 -0
  192. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/tasks/edit.py +0 -0
  193. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/tasks/extract_extras.py +0 -0
  194. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/tasks/llm.py +0 -0
  195. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/tasks/schema.py +0 -0
  196. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/tasks/split.py +0 -0
  197. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/textlayer.py +0 -0
  198. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/textnorm.py +0 -0
  199. {readanydoc-0.4.0 → readanydoc-0.4.2}/readanydoc/trace.py +0 -0
  200. {readanydoc-0.4.0 → readanydoc-0.4.2}/research/README.md +0 -0
  201. {readanydoc-0.4.0 → readanydoc-0.4.2}/research/benchmarks/README.md +0 -0
  202. {readanydoc-0.4.0 → readanydoc-0.4.2}/results/README.md +0 -0
  203. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/__init__.py +0 -0
  204. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/api/__init__.py +0 -0
  205. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/api/conftest.py +0 -0
  206. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/api/sdk_check.py +0 -0
  207. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/api/test_auth.py +0 -0
  208. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/api/test_cleanup.py +0 -0
  209. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/api/test_config_defaults.py +0 -0
  210. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/api/test_contract.py +0 -0
  211. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/api/test_e2e.py +0 -0
  212. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/api/test_jobs.py +0 -0
  213. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/api/test_sdk.py +0 -0
  214. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/api/test_webhooks.py +0 -0
  215. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/assembly/__init__.py +0 -0
  216. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/assembly/evaluate.py +0 -0
  217. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/assembly/synth.py +0 -0
  218. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/assembly/test_assembly.py +0 -0
  219. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/assembly/test_real_documents.py +0 -0
  220. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/checks/__init__.py +0 -0
  221. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/checks/test_checks_stage.py +0 -0
  222. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/checks/test_complete.py +0 -0
  223. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/checks/test_htmlgrid.py +0 -0
  224. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/checks/test_numbers.py +0 -0
  225. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/conftest.py +0 -0
  226. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/cost/__init__.py +0 -0
  227. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/cost/test_r3b_cost.py +0 -0
  228. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/figures/__init__.py +0 -0
  229. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/figures/test_figures.py +0 -0
  230. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/forms/__init__.py +0 -0
  231. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/forms/test_fillable.py +0 -0
  232. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/forms/test_grid.py +0 -0
  233. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/forms/test_lines_crops.py +0 -0
  234. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/forms/test_rules.py +0 -0
  235. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/grounding/__init__.py +0 -0
  236. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/grounding/test_grounding.py +0 -0
  237. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/intake/__init__.py +0 -0
  238. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/intake/test_intake.py +0 -0
  239. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/judge/__init__.py +0 -0
  240. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/judge/test_judge.py +0 -0
  241. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/reading/__init__.py +0 -0
  242. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/reading/test_handwriting_route.py +0 -0
  243. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/reading/test_live_profile.py +0 -0
  244. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/reading/test_reading_pipeline.py +0 -0
  245. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/reading/test_reading_units.py +0 -0
  246. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/reading/test_robustness.py +0 -0
  247. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/regions/__init__.py +0 -0
  248. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/regions/test_fields.py +0 -0
  249. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/regions/test_furniture.py +0 -0
  250. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/regions/test_regions.py +0 -0
  251. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/shaping/__init__.py +0 -0
  252. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/shaping/test_chunking.py +0 -0
  253. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/shaping/test_round2_options.py +0 -0
  254. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/shaping/test_tables.py +0 -0
  255. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/tables/__init__.py +0 -0
  256. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/tables/test_tables_round2.py +0 -0
  257. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/tasks/__init__.py +0 -0
  258. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/tasks/conftest.py +0 -0
  259. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/tasks/live_notes.md +0 -0
  260. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/tasks/live_smoke.py +0 -0
  261. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/tasks/test_edit.py +0 -0
  262. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/tasks/test_extract.py +0 -0
  263. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/tasks/test_extract_extras.py +0 -0
  264. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/tasks/test_extract_robust.py +0 -0
  265. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/tasks/test_llm.py +0 -0
  266. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/tasks/test_reply_schema.py +0 -0
  267. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/tasks/test_review.py +0 -0
  268. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/tasks/test_schema.py +0 -0
  269. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/tasks/test_split_classify.py +0 -0
  270. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/test_bench.py +0 -0
  271. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/test_engine_final.py +0 -0
  272. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/test_integrations.py +0 -0
  273. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/test_library.py +0 -0
  274. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/test_localmodels.py +0 -0
  275. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/test_mcp_server.py +0 -0
  276. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/test_model.py +0 -0
  277. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/test_pipeline.py +0 -0
  278. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/test_readers.py +0 -0
  279. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/test_robust_fallbacks.py +0 -0
  280. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/test_serializer.py +0 -0
  281. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/test_star.py +0 -0
  282. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/test_ws4_ocr_prep.py +0 -0
  283. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/test_ws4_speed_batch.py +0 -0
  284. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/test_zoom_vote.py +0 -0
  285. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/typing/__init__.py +0 -0
  286. {readanydoc-0.4.0 → readanydoc-0.4.2}/tests/typing/test_typing.py +0 -0
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.2 (2026-11-19)
4
+
5
+ From a user's test of 0.4.0 on a pack of 5 order forms (their scorer: 97.9% of fields right). After these fixes,
6
+ one run: 534 of 534 fields right, $0.012-0.015 per form.
7
+
8
+ - Required yes/no and enum fields come back in the schema's type. A field the schema requires and does not allow
9
+ null (a boolean, an enum) has no empty choice: the model has to answer it, so the output passes the schema's
10
+ own validation (4 of 5 forms returned null for a required boolean). In the coded format such fields are marked
11
+ "always answer". An optional section the document does not have is still null, and a list item is never made up
12
+ for such a field. Numbers and text are never forced: a required one the document does not give stays null, with
13
+ a warning.
14
+ - Alternatives (`alternatives=True`) come back in the field's own format and type ("2026-03-01", 4500), with the
15
+ printed text kept as `printed`.
16
+ - Review: no `not_found_on_page` for enum fields (a category the model picks is never printed as such); no
17
+ `list_may_be_incomplete` for a total row under the items; "&" in a name is matched against "&" in the parsed
18
+ table (a printed name was flagged as not printed).
19
+
20
+ ## 0.4.1 (2026-11-19)
21
+
22
+ - `readanydoc bench`: a small sample now covers the set's hard documents (photos, scans, handwriting,
23
+ multi-page) and mixes difficulties, instead of the first clean PDFs.
24
+ - BENCHMARKS.md: a 20-invoice extraction run against Reducto and a plain model.
25
+
3
26
  ## 0.4.0 (2026-11-19)
4
27
 
5
28
  Test it yourself: compare ReadAnyDoc with other systems on public test sets or your own documents.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: readanydoc
3
- Version: 0.4.0
3
+ Version: 0.4.2
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.0",
3
+ "version": "0.4.2",
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@587d4511ace2142756fe488ee7ec3b349d8690c1", "readanydoc", "mcp"]
5
+ "args": ["--from", "git+https://github.com/arpitpatel25/ReadAnyDoc@71184aae2561ba4da675b20c216c0844b7c5d12f", "readanydoc", "mcp"]
6
6
  }
7
7
  }
8
8
  }
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "readanydoc"
3
- version = "0.4.0"
3
+ version = "0.4.2"
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.0"
6
+ __version__ = "0.4.2"
7
7
 
8
8
  from .library import (Block, BoundingBox, Citation, ExtractResult, ParseResult, Usage, # noqa: E402
9
9
  extract, parse)
@@ -92,20 +92,42 @@ INVOICE_SCHEMA = {
92
92
  }
93
93
 
94
94
 
95
+ # Hard input types first, so that even a small sample has photos, scans and handwriting, not only clean PDFs.
96
+ _INVOICE_ORDER = ["photo", "scan", "handwritten", "multipage", "hard", "freight", "credit", "tax", "currency", "clean"]
97
+ _DIFFICULTY = ["hard", "medium", "easy"]
98
+
99
+
100
+ def _spread(meta: list[dict], limit: int) -> list[dict]:
101
+ """One document of every category before a second of any, each category's documents mixed across difficulties
102
+ (the starting difficulty rotates between categories), so a sample of any size covers the whole set."""
103
+ by: dict[str, list] = {}
104
+ for m in meta:
105
+ by.setdefault(m["category"], []).append(m)
106
+ cats = [c for c in _INVOICE_ORDER if c in by] + sorted(c for c in by if c not in _INVOICE_ORDER)
107
+ for ci, c in enumerate(cats):
108
+ levels = _DIFFICULTY[ci % 3:] + _DIFFICULTY[:ci % 3]
109
+ groups = [[m for m in by[c] if m.get("difficulty") == d] for d in levels]
110
+ groups.append([m for m in by[c] if m.get("difficulty") not in _DIFFICULTY])
111
+ mixed = []
112
+ while any(groups):
113
+ for g in groups:
114
+ if g:
115
+ mixed.append(g.pop(0))
116
+ by[c] = mixed
117
+ out, i = [], 0
118
+ while len(out) < min(limit, len(meta)):
119
+ for c in cats:
120
+ if i < len(by[c]) and len(out) < limit:
121
+ out.append(by[c][i])
122
+ i += 1
123
+ return out
124
+
125
+
95
126
  def _invoices(limit: Optional[int]) -> list[dict]:
96
127
  meta = [json.loads(l) for l in fetch.hf_file(INV_REPO, "corpus/v1/metadata.jsonl").read_text().splitlines()
97
128
  if l.strip()]
98
- if limit: # a spread of every category before more of any one
99
- by: dict[str, list] = {}
100
- for m in meta:
101
- by.setdefault(m["category"], []).append(m)
102
- mixed, i = [], 0
103
- while len(mixed) < min(limit, len(meta)):
104
- for c in sorted(by):
105
- if i < len(by[c]) and len(mixed) < limit:
106
- mixed.append(by[c][i])
107
- i += 1
108
- meta = mixed
129
+ if limit:
130
+ meta = _spread(meta, limit)
109
131
  out = []
110
132
  for m in meta:
111
133
  exp = m["expected"]
@@ -29,7 +29,9 @@ NOTE = ('Answer as {"values": [...]} with one entry per value: "code" is the fie
29
29
  "document states or makes clear for that item. A value the document states once for a whole table, "
30
30
  "column, section or page (a unit, a scale such as \"in thousands\", a currency, a date or period in a "
31
31
  "heading) applies to every item it covers: write it on each of those items. Leave out only a field the "
32
- "document gives no value for and does not make clear; never write a guess. A value the document gives in "
32
+ "document gives no value for and does not make clear; never write a guess. A field marked \"always answer\" is "
33
+ "required in every list item or section you write: never leave it out there, write the choice the "
34
+ "document\'s terms mean (it never makes you write an item or section the document does not have). A value the document gives in "
33
35
  "another form is not a guess: write it in the form the field asks for (a country name as its code). "
34
36
  'Write numbers as plain digits ("4200.50", "-1200") and dates in the format the field asks for. '
35
37
  'Copy names, titles and labels exactly as printed, every word of them, even when part of a name looks like '
@@ -53,9 +55,10 @@ class Leaf:
53
55
 
54
56
  def _describe(node: dict) -> str:
55
57
  bits = []
56
- enum = [e for e in (node.get("enum") or []) if e != ""]
57
- if enum:
58
- bits.append("one of: " + ", ".join(str(e) for e in enum))
58
+ raw = node.get("enum")
59
+ enum = [e for e in (raw or []) if e != ""]
60
+ if enum: # no "" choice: the user's schema requires this yes/no or enum (reply_schema.to_reply)
61
+ bits.append(("always answer, " if "" not in raw else "") + "one of: " + ", ".join(str(e) for e in enum))
59
62
  if node.get("description"):
60
63
  bits.append(str(node["description"]))
61
64
  if "anyOf" in node:
@@ -392,6 +392,16 @@ def _find_date(masked: str, value: str) -> list[tuple[int, int]]:
392
392
  return sorted(set(out))
393
393
 
394
394
 
395
+ _ENTITY = re.compile(r"&(?:amp|lt|gt|quot|apos|nbsp|#3[49]|#160|#x2[67]|#xa0);", re.I)
396
+
397
+
398
+ def _words(content: str) -> list:
399
+ """The block's words for matching a value: "&amp;" in the parsed HTML is the printed "&", not a word "amp"."""
400
+ if "&" in (content or ""):
401
+ content = _ENTITY.sub(lambda m: "<" + " " * (len(m.group(0)) - 2) + ">", content)
402
+ return tokenize(content)
403
+
404
+
395
405
  def _find_tokens(tokens: list, want: list[str]) -> list[tuple[int, int]]:
396
406
  n = len(want)
397
407
  if not n or n > len(tokens):
@@ -428,12 +438,12 @@ def spans(value: Any, ref: RegionRef) -> tuple[list[tuple[int, int]], bool]:
428
438
  if as_num is not None:
429
439
  found = _find_number(masked, as_num)
430
440
  if not found and not isinstance(value, (int, float)) and not _PLAIN_NUMBER.fullmatch(str(value).strip()):
431
- found = _find_tokens(tokenize(content), norm_tokens(str(value))) # "INV-2041": text that holds a number
441
+ found = _find_tokens(_words(content), norm_tokens(str(value))) # "INV-2041": text that holds a number
432
442
  return found, True
433
443
  want = norm_tokens(str(value))
434
444
  if not want:
435
445
  return [], True
436
- found = _find_tokens(tokenize(content), want)
446
+ found = _find_tokens(_words(content), want)
437
447
  if not found and _ISO_DATE.match(str(value)):
438
448
  found = _find_date(masked, str(value))
439
449
  if not found and len(want) >= 4:
@@ -2059,11 +2069,15 @@ def run(document: Any, config: dict, *, llm: LLM, options: Optional[dict] = None
2059
2069
  if alt_cfg and use_reply:
2060
2070
  found: dict[str, list] = {}
2061
2071
  for a in alts:
2062
- item = {"value": str(a.get("value", "")).strip(), "note": str(a.get("note", "")).strip() or None}
2072
+ key = str(a.get("field", "")).strip()
2073
+ text = str(a.get("value", "")).strip()
2074
+ printed = str(a.get("printed", "")).strip() or text
2075
+ leaf = _schema_at(ex.strict, key)
2076
+ item = {"value": _as_field(text, leaf), "printed": printed,
2077
+ "note": str(a.get("note", "")).strip() or None}
2063
2078
  if citations_on:
2064
- hit = ex.found_anywhere(item["value"])
2079
+ hit = ex.found_anywhere(printed) or ex.found_anywhere(text)
2065
2080
  item["citations"] = [_citation(hit[0][0], hit[0][1], 0.8, cit_cfg)] if hit else []
2066
- key = str(a.get("field", "")).strip()
2067
2081
  if key and item not in found.setdefault(key, []):
2068
2082
  found[key].append(item)
2069
2083
  extra_out["alternatives"] = found
@@ -2080,3 +2094,30 @@ def run(document: Any, config: dict, *, llm: LLM, options: Optional[dict] = None
2080
2094
  return {"response_type": "v3_extract", "result": result, "usage": usage,
2081
2095
  "studio_link": None, "confidence": confidence, "confidence_reason": reason,
2082
2096
  "warnings": warnings, **extra_out}
2097
+
2098
+
2099
+ def _schema_at(schema: Any, key: str) -> Any:
2100
+ """The user's schema for a field path as the model writes it ("contract.items[0].amount", or with a name in the
2101
+ brackets), or None when the path does not lead to a field."""
2102
+ node = schema
2103
+ for name, bracket in re.findall(r"([^.\[\]]+)|\[([^\]]*)\]", key or ""):
2104
+ live = S.branch_for(node, [] if bracket or not name else {}) if isinstance(node, dict) else None
2105
+ if not isinstance(live, dict):
2106
+ return None
2107
+ if name:
2108
+ if S.is_array(live) and not S.is_object(live): # "items.amount" without an index
2109
+ live = S.branch_for(live.get("items") or {}, {})
2110
+ node = (live.get("properties") or {}).get(name) if S.is_object(live) else None
2111
+ else:
2112
+ node = live.get("items") if S.is_array(live) else None
2113
+ if node is None:
2114
+ return None
2115
+ return node
2116
+
2117
+
2118
+ def _as_field(text: str, leaf: Any) -> Any:
2119
+ """An alternative value in the field's own type ("4500" -> 4500 for a number), like the main value."""
2120
+ if not isinstance(leaf, dict) or S.is_object(leaf) or S.is_array(leaf):
2121
+ return text
2122
+ v = S.conform(RS.from_reply(text, leaf), leaf)
2123
+ return text if v is None else v
@@ -209,6 +209,8 @@ def amount_rows(content: str) -> int:
209
209
  cells = [" ".join(re.sub(r"<[^>]+>", " ", x).split()) for x in re.findall(r"<td\b[^>]*>(.*?)</td>", row, re.I | re.S)]
210
210
  if any(_SUMMARY_ROW.search(x) for x in cells if x) or not any(_AMOUNT.search(x) for x in cells if x):
211
211
  continue
212
+ if cells and not cells[0]: # no item name in the first column: a total under the items ("| Monthly | 5,800")
213
+ continue
212
214
  n += 1
213
215
  return n
214
216
  lines = [ln for ln in c.splitlines() if ln.strip().startswith("|")]
@@ -217,6 +219,15 @@ def amount_rows(content: str) -> int:
217
219
  return sum(1 for ln in body if not _SUMMARY_ROW.search(ln) and _AMOUNT.search(ln))
218
220
 
219
221
 
222
+ def _category(leaf: Any) -> bool:
223
+ """An enum or const field: a category the model picks (a pricing model, a billing cadence code), which is not
224
+ printed on the page as such, so "not printed" says nothing about it."""
225
+ if not isinstance(leaf, dict):
226
+ return False
227
+ nodes = [leaf] + [b for b in (leaf.get("anyOf") or leaf.get("oneOf") or []) if isinstance(b, dict)]
228
+ return any("const" in n or isinstance(n.get("enum"), list) for n in nodes)
229
+
230
+
220
231
  def review(value: Any, schema: Any, cites: dict, ex: Any, *, conflicts: list, unreadable: set,
221
232
  pages: list[PageRef]) -> list[dict]:
222
233
  """[{"field", "flag", "detail"}] for the values a reader should check (see the module docstring)."""
@@ -228,12 +239,12 @@ def review(value: Any, schema: Any, cites: dict, ex: Any, *, conflicts: list, un
228
239
  if item not in out:
229
240
  out.append(item)
230
241
 
231
- for path, v, _ in S.iter_leaves(value, schema):
242
+ for path, v, _leaf in S.iter_leaves(value, schema):
232
243
  if not path or v is None or isinstance(v, bool):
233
244
  continue
234
245
  key = S.path_str(path)
235
246
  good = [c for c in cites.get(path) or [] if c.get("confidence") == "high"]
236
- if not good:
247
+ if not good and not _category(_leaf):
237
248
  add(key, "not_found_on_page", "not printed in the document as returned: worked out, converted or assumed")
238
249
  for c in good[:1]:
239
250
  for flag, note in format_flags(v, c.get("content"), (c.get("parentBlock") or {}).get("content", "")):
@@ -7,7 +7,9 @@ nullable, is over both after a dozen fields, so the model used to write free JSO
7
7
  ``to_reply`` rewrites the user's schema (``$ref``-free) into one the API accepts, in code, before the call:
8
8
 
9
9
  - every field is required, and "or null" is dropped: an empty string means "not in the document", an empty list
10
- an empty list; a field is never forced to hold a guess, because "" is always a valid answer;
10
+ an empty list; a number or text is never forced to hold a guess, because "" is always a valid answer for it;
11
+ - a yes/no or enum field that the user's schema requires and does not allow null has no "" choice: the model has
12
+ to answer it (as the user's schema demands), so the output does not break the user's own validation;
11
13
  - numbers, integers and booleans become strings (the value as printed: "$4,200.00", "yes"), so they need no
12
14
  null either; enums keep their values plus "".
13
15
 
@@ -64,21 +66,29 @@ def _live(node: dict) -> list:
64
66
  return [b for b in br if S.types_of(b) != {"null"} and b != {"type": "null"}]
65
67
 
66
68
 
67
- def to_reply(schema: Any) -> Any:
68
- """The structured-output version of a resolved schema (see the module docstring)."""
69
+ def to_reply(schema: Any, must: bool = True) -> Any:
70
+ """The structured-output version of a resolved schema (see the module docstring).
71
+
72
+ ``must``: the user's schema requires this value and does not allow null, and every object above it is always
73
+ present (required, not nullable). A yes/no, enum or const field like that gets no "" choice: the API makes the
74
+ model answer it, so the output never breaks the user's required type. Other required fields keep "" (no
75
+ number or text is ever made up); one that comes back empty is reported (``required_warnings``)."""
69
76
  if not isinstance(schema, dict):
70
77
  return {"type": "string"}
78
+ must = must and not _allows_null(schema)
71
79
  live = _live(schema)
72
80
  if len(live) == 1 and live[0] is not schema:
73
81
  merged = {**{k: v for k, v in schema.items() if k not in ("anyOf", "oneOf")}, **live[0]}
74
- return to_reply(merged)
82
+ return to_reply(merged, must)
75
83
  if len(live) > 1:
76
- return {"anyOf": [to_reply(b) for b in live], **_desc(schema)}
84
+ return {"anyOf": [to_reply(b, False) for b in live], **_desc(schema)}
77
85
  ts = S.types_of(schema) - {"null"}
86
+ empty = [] if must else [""]
78
87
  if "const" in schema:
79
- return {"type": "string", "enum": [str(schema["const"]), ""], **_desc(schema)}
88
+ return {"type": "string", "enum": [str(schema["const"])] + empty, **_desc(schema)}
80
89
  if S.is_object(schema) or ("object" in ts and "properties" in schema):
81
- props = {k: to_reply(v) for k, v in (schema.get("properties") or {}).items()}
90
+ req, forced = set(schema.get("required") or []), _forced(schema, must)
91
+ props = {k: to_reply(v, k in forced or (must and k in req)) for k, v in (schema.get("properties") or {}).items()}
82
92
  return {"type": "object", "properties": props, "required": list(props), "additionalProperties": False,
83
93
  **_desc(schema)}
84
94
  if "array" in ts or "items" in schema:
@@ -86,9 +96,9 @@ def to_reply(schema: Any) -> Any:
86
96
  enum = schema.get("enum")
87
97
  if isinstance(enum, list):
88
98
  vals = [str(v).lower() if isinstance(v, bool) else str(v) for v in enum if v is not None]
89
- return {"type": "string", "enum": list(dict.fromkeys(vals + [""])), **_desc(schema)}
99
+ return {"type": "string", "enum": list(dict.fromkeys(vals + empty)) or [""], **_desc(schema)}
90
100
  if ts == {"boolean"}:
91
- return {"type": "string", "enum": ["true", "false", ""], **_desc(schema)}
101
+ return {"type": "string", "enum": ["true", "false"] + empty, **_desc(schema)}
92
102
  if ts & {"number", "integer"} and "string" not in ts:
93
103
  return {"type": "string", **_desc(schema, "a number")}
94
104
  return {"type": "string", **_desc(schema)}
@@ -108,14 +118,22 @@ def from_reply(value: Any, schema: Any) -> Any:
108
118
  return None if value in ("", None) else value
109
119
  out = {k: from_reply(value.get(k), sub) for k, sub in schema["properties"].items()} | \
110
120
  {k: v for k, v in value.items() if k not in schema["properties"]}
111
- # an optional object the document does not have comes back as null, as the user's schema allows
112
- return None if nullable and _blank(out) else out
121
+ # an optional object the document does not have comes back as null, as the user's schema allows; its
122
+ # yes/no and enum fields that had to be answered (``_forced``) do not count as something found
123
+ forced = _forced(schema, False)
124
+ return None if nullable and _blank({k: v for k, v in out.items() if k not in forced}) else out
113
125
  if S.is_array(schema):
114
126
  if value in ("", None):
115
127
  return []
116
128
  if not isinstance(value, list):
117
129
  return value
118
- return [from_reply(v, schema.get("items") or {}) for v in value]
130
+ items = schema.get("items") or {}
131
+ out = [from_reply(v, items) for v in value]
132
+ live = S.branch_for(items, {}) if isinstance(items, dict) else None
133
+ forced = _forced(live, False) if isinstance(live, dict) and S.is_object(live) else set()
134
+ if forced: # an item holding only answers it was made to give is not an item the document has
135
+ out = [x for x in out if not (isinstance(x, dict) and _blank({k: v for k, v in x.items() if k not in forced}))]
136
+ return out
119
137
  if isinstance(value, str):
120
138
  v = value.strip()
121
139
  if not v:
@@ -143,6 +161,24 @@ def from_reply(value: Any, schema: Any) -> Any:
143
161
  return value
144
162
 
145
163
 
164
+ def _choice(node: Any) -> bool:
165
+ """A yes/no, enum or const field: one whose answer can be forced without making up a number or text."""
166
+ if not isinstance(node, dict):
167
+ return False
168
+ live = _live(node)
169
+ n = live[0] if len(live) == 1 else node
170
+ return isinstance(n, dict) and ("const" in n or isinstance(n.get("enum"), list)
171
+ or S.types_of(n) - {"null"} == {"boolean"})
172
+
173
+
174
+ def _forced(obj: dict, must: bool) -> set:
175
+ """Fields of an object answered without a "" choice: required, not nullable, yes/no or enum. In an object that
176
+ may be absent and has nothing else to find, none are forced (forcing them would make the object up)."""
177
+ req, props = set(obj.get("required") or []), obj.get("properties") or {}
178
+ keys = {k for k, v in props.items() if k in req and isinstance(v, dict) and not _allows_null(v) and _choice(v)}
179
+ return keys if must or len(keys) < len(props) else set()
180
+
181
+
146
182
  def _allows_null(schema: dict) -> bool:
147
183
  t = schema.get("type")
148
184
  if t == "null" or (isinstance(t, list) and "null" in t):
@@ -361,8 +397,10 @@ def add_alternatives(reply: dict, fields: Optional[list[str]]) -> dict:
361
397
  "none." + which),
362
398
  "items": {"type": "object", "properties": {
363
399
  "field": {"type": "string", "description": "path of the field, e.g. contract.price or items[0].amount"},
364
- "value": {"type": "string", "description": "the other value, as printed"},
400
+ "value": {"type": "string", "description": "the other value, written the way the field asks for its "
401
+ "answer (same format as the answer: a date in the field's date format, a number as digits)"},
402
+ "printed": {"type": "string", "description": "the same value as printed in the document"},
365
403
  "note": {"type": "string", "description": "why it differs, in a few words"}},
366
- "required": ["field", "value", "note"], "additionalProperties": False}}
404
+ "required": ["field", "value", "printed", "note"], "additionalProperties": False}}
367
405
  reply["required"] = list(reply.get("required", [])) + [ALT_FIELD]
368
406
  return reply
@@ -0,0 +1,53 @@
1
+ """Required yes/no and enum fields come back in the user's type; review and alternatives follow the field."""
2
+ from readanydoc.tasks import reply_schema as RS
3
+ from readanydoc.tasks import extract as E
4
+ from readanydoc.tasks import field_report as FR
5
+
6
+ TERMS = {"type": "object", "required": ["mode", "days", "last_day"], "properties": {
7
+ "mode": {"type": "string", "enum": ["relative", "absolute"]},
8
+ "days": {"type": "integer"},
9
+ "last_day": {"type": "boolean"}}}
10
+ SCHEMA = {"type": "object", "required": ["flag", "terms"], "properties": {
11
+ "flag": {"type": "boolean"},
12
+ "note": {"type": "boolean"},
13
+ "maybe": {"anyOf": [{"type": "boolean"}, {"type": "null"}]},
14
+ "terms": {"anyOf": [TERMS, {"type": "null"}]},
15
+ "items": {"type": "array", "items": {"type": "object", "required": ["kind"], "properties": {
16
+ "kind": {"type": "string", "enum": ["fixed", "percent"]}, "value": {"type": "number"}}}}}}
17
+
18
+
19
+ def test_required_choices_have_no_empty_option():
20
+ r = RS.to_reply(SCHEMA)["properties"]
21
+ assert r["flag"]["enum"] == ["true", "false"]
22
+ assert "" in r["note"]["enum"] and "" in r["maybe"]["enum"] # optional or nullable: may stay empty
23
+ t = r["terms"]["properties"]
24
+ assert t["last_day"]["enum"] == ["true", "false"] and t["mode"]["enum"] == ["relative", "absolute"]
25
+ assert r["items"]["items"]["properties"]["kind"]["enum"] == ["fixed", "percent"]
26
+
27
+
28
+ def test_absent_optional_object_and_items_are_not_made_up():
29
+ got = RS.from_reply({"flag": "false", "terms": {"mode": "relative", "days": "", "last_day": "false"},
30
+ "items": [{"kind": "fixed", "value": ""}, {"kind": "percent", "value": "10"}]}, SCHEMA)
31
+ assert got["flag"] is False and got["terms"] is None
32
+ assert [i["kind"] for i in got["items"]] == ["percent"]
33
+ kept = RS.from_reply({"terms": {"mode": "relative", "days": "30", "last_day": "false"}}, SCHEMA)["terms"]
34
+ assert kept["last_day"] is False
35
+
36
+
37
+ def test_alternative_values_take_the_field_type():
38
+ leaf = E._schema_at(SCHEMA, "items[0].value")
39
+ assert leaf == {"type": "number"} and E._as_field("4,500.00", leaf) == 4500
40
+ assert E._schema_at(SCHEMA, "terms.last_day") == {"type": "boolean"}
41
+ assert E._schema_at(SCHEMA, "nope.x") is None and E._as_field("x", None) == "x"
42
+
43
+
44
+ def test_html_entity_is_not_a_word():
45
+ assert [t.norm for t in E._words("<td>Harbor &amp; Pine</td>")] == ["harbor", "pine"]
46
+
47
+
48
+ def test_total_row_without_item_name_is_not_an_item():
49
+ t = ("<table><tr><td>Product</td><td>Amount</td></tr><tr><td>A</td><td>USD 10.00</td></tr>"
50
+ "<tr><td>B</td><td>USD 20.00</td></tr><tr><td></td><td>USD 30.00</td></tr></table>")
51
+ assert FR.amount_rows(t) == 2
52
+ assert FR._category({"enum": ["a"]}) and FR._category({"anyOf": [{"enum": ["a"]}, {"type": "null"}]})
53
+ assert not FR._category({"type": "string"})
@@ -100,3 +100,16 @@ def test_every_listed_system_can_be_built_and_names_its_key():
100
100
  def test_the_catalogue_lists_licence_and_source_for_every_set():
101
101
  for s in catalog.SETS.values():
102
102
  assert s.licence and s.source.startswith("https://") and s.documents > 0 and s.default_limit > 0
103
+
104
+
105
+ def test_small_invoice_sample_covers_hard_input_types():
106
+ from readanydoc.bench.catalog import _spread
107
+ meta = [{"category": c, "difficulty": d, "doc_id": f"{c}-{d}-{i}"}
108
+ for c in ["clean", "credit", "currency", "photo", "scan", "handwritten"]
109
+ for d in ["easy", "medium", "hard"] for i in range(2)]
110
+ three = _spread(meta, 3)
111
+ assert [m["category"] for m in three] == ["photo", "scan", "handwritten"]
112
+ assert len({m["difficulty"] for m in three}) == 3
113
+ every = _spread(meta, len(meta))
114
+ assert sorted(m["doc_id"] for m in every) == sorted(m["doc_id"] for m in meta)
115
+ assert {m["category"] for m in _spread(meta, 6)} == {"clean", "credit", "currency", "photo", "scan", "handwritten"}
File without changes
File without changes
File without changes
File without changes