universal-doc-parser 1.0.0__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 (118) hide show
  1. universal_doc_parser-1.0.0/.github/workflows/ci.yml +51 -0
  2. universal_doc_parser-1.0.0/.github/workflows/release.yml +35 -0
  3. universal_doc_parser-1.0.0/.gitignore +161 -0
  4. universal_doc_parser-1.0.0/.python-version +1 -0
  5. universal_doc_parser-1.0.0/CHANGELOG.md +78 -0
  6. universal_doc_parser-1.0.0/LICENSE +21 -0
  7. universal_doc_parser-1.0.0/PKG-INFO +692 -0
  8. universal_doc_parser-1.0.0/README.md +651 -0
  9. universal_doc_parser-1.0.0/assets/banner.png +0 -0
  10. universal_doc_parser-1.0.0/assets/logo.png +0 -0
  11. universal_doc_parser-1.0.0/benchmarks/memory_profile.py +125 -0
  12. universal_doc_parser-1.0.0/benchmarks/providers/__init__.py +33 -0
  13. universal_doc_parser-1.0.0/benchmarks/providers/anthropic/__init__.py +4 -0
  14. universal_doc_parser-1.0.0/benchmarks/providers/anthropic/opus.py +14 -0
  15. universal_doc_parser-1.0.0/benchmarks/providers/anthropic/sonnet.py +14 -0
  16. universal_doc_parser-1.0.0/benchmarks/providers/base.py +164 -0
  17. universal_doc_parser-1.0.0/benchmarks/providers/cohere/__init__.py +5 -0
  18. universal_doc_parser-1.0.0/benchmarks/providers/cohere/command_r_plus.py +14 -0
  19. universal_doc_parser-1.0.0/benchmarks/providers/deepseek/__init__.py +4 -0
  20. universal_doc_parser-1.0.0/benchmarks/providers/deepseek/r1.py +14 -0
  21. universal_doc_parser-1.0.0/benchmarks/providers/deepseek/v3.py +14 -0
  22. universal_doc_parser-1.0.0/benchmarks/providers/gemini/__init__.py +4 -0
  23. universal_doc_parser-1.0.0/benchmarks/providers/gemini/flash.py +81 -0
  24. universal_doc_parser-1.0.0/benchmarks/providers/gemini/pro.py +81 -0
  25. universal_doc_parser-1.0.0/benchmarks/providers/glm/__init__.py +5 -0
  26. universal_doc_parser-1.0.0/benchmarks/providers/glm/glm4.py +14 -0
  27. universal_doc_parser-1.0.0/benchmarks/providers/kimi/__init__.py +5 -0
  28. universal_doc_parser-1.0.0/benchmarks/providers/kimi/k1_5.py +14 -0
  29. universal_doc_parser-1.0.0/benchmarks/providers/meta/__init__.py +5 -0
  30. universal_doc_parser-1.0.0/benchmarks/providers/meta/llama3_3.py +14 -0
  31. universal_doc_parser-1.0.0/benchmarks/providers/mistral/__init__.py +5 -0
  32. universal_doc_parser-1.0.0/benchmarks/providers/mistral/mistral_large.py +14 -0
  33. universal_doc_parser-1.0.0/benchmarks/providers/openai/__init__.py +4 -0
  34. universal_doc_parser-1.0.0/benchmarks/providers/openai/gpt4o.py +14 -0
  35. universal_doc_parser-1.0.0/benchmarks/providers/openai/gpt4o_mini.py +14 -0
  36. universal_doc_parser-1.0.0/benchmarks/providers/qwen/__init__.py +4 -0
  37. universal_doc_parser-1.0.0/benchmarks/providers/qwen/qwen_72b.py +14 -0
  38. universal_doc_parser-1.0.0/benchmarks/providers/qwen/qwen_coder.py +14 -0
  39. universal_doc_parser-1.0.0/benchmarks/run_llm_benchmark.py +134 -0
  40. universal_doc_parser-1.0.0/benchmarks/test_messy_document.py +147 -0
  41. universal_doc_parser-1.0.0/docs/ADDING_A_FORMAT.md +0 -0
  42. universal_doc_parser-1.0.0/docs/ARCHITECTURE.md +0 -0
  43. universal_doc_parser-1.0.0/docs/CHANGELOG.md +0 -0
  44. universal_doc_parser-1.0.0/docs/SCHEMA.md +0 -0
  45. universal_doc_parser-1.0.0/main.py +6 -0
  46. universal_doc_parser-1.0.0/pyproject.toml +67 -0
  47. universal_doc_parser-1.0.0/tests/__init__.py +0 -0
  48. universal_doc_parser-1.0.0/tests/fixtures/csv/sample.csv +4 -0
  49. universal_doc_parser-1.0.0/tests/fixtures/csv/sample.tsv +4 -0
  50. universal_doc_parser-1.0.0/tests/fixtures/docx/sample.docx +0 -0
  51. universal_doc_parser-1.0.0/tests/fixtures/html/sample.html +14 -0
  52. universal_doc_parser-1.0.0/tests/fixtures/json/sample_nested.json +8 -0
  53. universal_doc_parser-1.0.0/tests/fixtures/json/sample_tabular.json +5 -0
  54. universal_doc_parser-1.0.0/tests/fixtures/pdf/sample.pdf +0 -0
  55. universal_doc_parser-1.0.0/tests/fixtures/xlsx/sample.xlsx +0 -0
  56. universal_doc_parser-1.0.0/tests/fixtures/xml/sample.xml +5 -0
  57. universal_doc_parser-1.0.0/tests/test_adaptive.py +190 -0
  58. universal_doc_parser-1.0.0/tests/test_benchmark_providers.py +53 -0
  59. universal_doc_parser-1.0.0/tests/test_csv.py +48 -0
  60. universal_doc_parser-1.0.0/tests/test_docx.py +48 -0
  61. universal_doc_parser-1.0.0/tests/test_epub.py +50 -0
  62. universal_doc_parser-1.0.0/tests/test_exports.py +66 -0
  63. universal_doc_parser-1.0.0/tests/test_html.py +34 -0
  64. universal_doc_parser-1.0.0/tests/test_image.py +47 -0
  65. universal_doc_parser-1.0.0/tests/test_json_xml.py +51 -0
  66. universal_doc_parser-1.0.0/tests/test_legacy.py +42 -0
  67. universal_doc_parser-1.0.0/tests/test_mail.py +49 -0
  68. universal_doc_parser-1.0.0/tests/test_mcp.py +33 -0
  69. universal_doc_parser-1.0.0/tests/test_observability.py +56 -0
  70. universal_doc_parser-1.0.0/tests/test_parquet.py +41 -0
  71. universal_doc_parser-1.0.0/tests/test_pdf.py +100 -0
  72. universal_doc_parser-1.0.0/tests/test_pptx.py +68 -0
  73. universal_doc_parser-1.0.0/tests/test_xlsx.py +51 -0
  74. universal_doc_parser-1.0.0/universal_parser/__init__.py +28 -0
  75. universal_doc_parser-1.0.0/universal_parser/adaptive/__init__.py +17 -0
  76. universal_doc_parser-1.0.0/universal_parser/adaptive/config_cache.py +127 -0
  77. universal_doc_parser-1.0.0/universal_parser/adaptive/fingerprint.py +133 -0
  78. universal_doc_parser-1.0.0/universal_parser/adaptive/tuner.py +97 -0
  79. universal_doc_parser-1.0.0/universal_parser/core/__init__.py +0 -0
  80. universal_doc_parser-1.0.0/universal_parser/core/engine.py +55 -0
  81. universal_doc_parser-1.0.0/universal_parser/core/router.py +38 -0
  82. universal_doc_parser-1.0.0/universal_parser/core/schema.py +58 -0
  83. universal_doc_parser-1.0.0/universal_parser/core/sniffer.py +125 -0
  84. universal_doc_parser-1.0.0/universal_parser/enrichment/__init__.py +0 -0
  85. universal_doc_parser-1.0.0/universal_parser/enrichment/vlm_enricher.py +0 -0
  86. universal_doc_parser-1.0.0/universal_parser/exports/__init__.py +1 -0
  87. universal_doc_parser-1.0.0/universal_parser/exports/to_chunks.py +108 -0
  88. universal_doc_parser-1.0.0/universal_parser/exports/to_graph.py +114 -0
  89. universal_doc_parser-1.0.0/universal_parser/exports/to_markdown.py +31 -0
  90. universal_doc_parser-1.0.0/universal_parser/extractors/__init__.py +0 -0
  91. universal_doc_parser-1.0.0/universal_parser/extractors/base.py +39 -0
  92. universal_doc_parser-1.0.0/universal_parser/extractors/images/__init__.py +0 -0
  93. universal_doc_parser-1.0.0/universal_parser/extractors/images/scan_extractor.py +79 -0
  94. universal_doc_parser-1.0.0/universal_parser/extractors/mail/__init__.py +0 -0
  95. universal_doc_parser-1.0.0/universal_parser/extractors/mail/mail_extractor.py +206 -0
  96. universal_doc_parser-1.0.0/universal_parser/extractors/office/__init__.py +0 -0
  97. universal_doc_parser-1.0.0/universal_parser/extractors/office/docx_extractor.py +131 -0
  98. universal_doc_parser-1.0.0/universal_parser/extractors/office/legacy_extractor.py +112 -0
  99. universal_doc_parser-1.0.0/universal_parser/extractors/office/pptx_extractor.py +109 -0
  100. universal_doc_parser-1.0.0/universal_parser/extractors/office/xlsx_extractor.py +93 -0
  101. universal_doc_parser-1.0.0/universal_parser/extractors/pdf/__init__.py +0 -0
  102. universal_doc_parser-1.0.0/universal_parser/extractors/pdf/native.py +331 -0
  103. universal_doc_parser-1.0.0/universal_parser/extractors/pdf/tables.py +155 -0
  104. universal_doc_parser-1.0.0/universal_parser/extractors/pdf/visual_onnx.py +0 -0
  105. universal_doc_parser-1.0.0/universal_parser/extractors/structured/__init__.py +0 -0
  106. universal_doc_parser-1.0.0/universal_parser/extractors/structured/csv_extractor.py +86 -0
  107. universal_doc_parser-1.0.0/universal_parser/extractors/structured/json_xml_extractor.py +104 -0
  108. universal_doc_parser-1.0.0/universal_parser/extractors/structured/parquet_extractor.py +59 -0
  109. universal_doc_parser-1.0.0/universal_parser/extractors/web/__init__.py +1 -0
  110. universal_doc_parser-1.0.0/universal_parser/extractors/web/epub_extractor.py +81 -0
  111. universal_doc_parser-1.0.0/universal_parser/extractors/web/html_extractor.py +111 -0
  112. universal_doc_parser-1.0.0/universal_parser/mcp/__init__.py +1 -0
  113. universal_doc_parser-1.0.0/universal_parser/mcp/server.py +61 -0
  114. universal_doc_parser-1.0.0/universal_parser/observability/__init__.py +12 -0
  115. universal_doc_parser-1.0.0/universal_parser/observability/dashboard.py +231 -0
  116. universal_doc_parser-1.0.0/universal_parser/observability/logger.py +0 -0
  117. universal_doc_parser-1.0.0/universal_parser/observability/metrics.py +99 -0
  118. universal_doc_parser-1.0.0/uv.lock +2456 -0
@@ -0,0 +1,51 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: ["main"]
6
+ pull_request:
7
+ branches: ["main"]
8
+
9
+ jobs:
10
+ test:
11
+ name: Test (${{ matrix.os }} - Python ${{ matrix.python-version }})
12
+ runs-on: ${{ matrix.os }}
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ os: [ubuntu-latest, macos-latest, windows-latest]
17
+ python-version: ["3.11", "3.12"]
18
+
19
+ steps:
20
+ - name: Checkout repository
21
+ uses: actions/checkout@v4
22
+
23
+ - name: Set up uv
24
+ uses: astral-sh/setup-uv@v5
25
+ with:
26
+ enable-cache: true
27
+
28
+ - name: Set up Python ${{ matrix.python-version }}
29
+ uses: actions/setup-python@v5
30
+ with:
31
+ python-version: ${{ matrix.python-version }}
32
+
33
+ - name: Install system dependencies (Linux)
34
+ if: runner.os == 'Linux'
35
+ run: |
36
+ sudo apt-get update
37
+ sudo apt-get install -y libmagic1 libgl1
38
+
39
+ - name: Install system dependencies (macOS)
40
+ if: runner.os == 'macOS'
41
+ run: |
42
+ brew install libmagic
43
+
44
+ - name: Install Python dependencies
45
+ run: uv sync --all-extras
46
+
47
+ - name: Lint with Ruff
48
+ run: uv run ruff check .
49
+
50
+ - name: Run Test Suite
51
+ run: uv run pytest -v
@@ -0,0 +1,35 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ publish:
10
+ name: Build and Publish to PyPI
11
+ runs-on: ubuntu-latest
12
+ permissions:
13
+ id-token: write
14
+ contents: write
15
+
16
+ steps:
17
+ - name: Checkout repository
18
+ uses: actions/checkout@v4
19
+
20
+ - name: Install uv
21
+ uses: astral-sh/setup-uv@v3
22
+ with:
23
+ enable-cache: true
24
+
25
+ - name: Set up Python
26
+ run: uv python install 3.11
27
+
28
+ - name: Build package distribution
29
+ run: uv build
30
+
31
+ - name: Publish package distributions to PyPI
32
+ uses: pypa/gh-action-pypi-publish@release/v1
33
+ with:
34
+ packages-dir: dist/
35
+ skip-existing: true
@@ -0,0 +1,161 @@
1
+ # -------------------------------------------------------
2
+ # PROJECT INTERNALS — never push these
3
+ # -------------------------------------------------------
4
+
5
+ # The core build plan and architecture ideas
6
+ universal-parser-build-plan.md
7
+
8
+ # Local notes, scratch files, private planning docs
9
+ notes/
10
+ scratch/
11
+ *.private.md
12
+ *.local.md
13
+ TODO.local.md
14
+ PARSE ANYTHING.png
15
+ *.png
16
+ !assets/*.png
17
+ !tests/fixtures/**/*.png
18
+
19
+
20
+ # -------------------------------------------------------
21
+ # CREDENTIALS & SECRETS — absolute never
22
+ # -------------------------------------------------------
23
+ .env
24
+ .env.*
25
+ !.env.example
26
+ *.key
27
+ *.pem
28
+ *.p12
29
+ *.pfx
30
+ secrets/
31
+ credentials/
32
+ config/local*.json
33
+ config/local*.yaml
34
+ config/local*.toml
35
+
36
+ # -------------------------------------------------------
37
+ # PYTHON
38
+ # -------------------------------------------------------
39
+ __pycache__/
40
+ *.py[cod]
41
+ *$py.class
42
+ *.so
43
+ *.egg
44
+ *.egg-info/
45
+ dist/
46
+ build/
47
+ eggs/
48
+ parts/
49
+ var/
50
+ sdist/
51
+ wheels/
52
+ pip-wheel-metadata/
53
+ share/python-wheels/
54
+ MANIFEST
55
+
56
+ # Virtual environments
57
+ .venv/
58
+ venv/
59
+ env/
60
+ ENV/
61
+ .Python
62
+
63
+ # uv
64
+ .uv/
65
+
66
+ # Type checking
67
+ .mypy_cache/
68
+ .dmypy.json
69
+ dmypy.json
70
+ .pytype/
71
+ .pyre/
72
+
73
+ # -------------------------------------------------------
74
+ # TESTING & COVERAGE
75
+ # -------------------------------------------------------
76
+ .pytest_cache/
77
+ .coverage
78
+ .coverage.*
79
+ coverage.xml
80
+ htmlcov/
81
+ *.coveragerc
82
+ .hypothesis/
83
+ .tox/
84
+ benchmarks/temp/
85
+
86
+ # -------------------------------------------------------
87
+ # EDITORS & IDEs
88
+ # -------------------------------------------------------
89
+
90
+ # VS Code
91
+ .vscode/
92
+ *.code-workspace
93
+
94
+ # JetBrains (PyCharm, etc.)
95
+ .idea/
96
+ *.iml
97
+ *.iws
98
+
99
+ # Vim / Neovim
100
+ *.swp
101
+ *.swo
102
+ *~
103
+ Session.vim
104
+
105
+ # Emacs
106
+ *#
107
+ .#*
108
+
109
+ # Sublime Text
110
+ *.sublime-project
111
+ *.sublime-workspace
112
+
113
+ # -------------------------------------------------------
114
+ # OS FILES
115
+ # -------------------------------------------------------
116
+
117
+ # Windows
118
+ Thumbs.db
119
+ ehthumbs.db
120
+ Desktop.ini
121
+ $RECYCLE.BIN/
122
+ *.lnk
123
+
124
+ # macOS
125
+ .DS_Store
126
+ .AppleDouble
127
+ .LSOverride
128
+ ._*
129
+ .Spotlight-V100
130
+ .Trashes
131
+
132
+ # Linux
133
+ .directory
134
+
135
+ # -------------------------------------------------------
136
+ # LOGS & RUNTIME
137
+ # -------------------------------------------------------
138
+ *.log
139
+ logs/
140
+ *.pid
141
+ *.seed
142
+ *.pid.lock
143
+
144
+ # -------------------------------------------------------
145
+ # BENCHMARK OUTPUTS — generated, not source
146
+ # -------------------------------------------------------
147
+ benchmarks/results/
148
+ benchmarks/*.json
149
+ benchmarks/*.csv
150
+
151
+ # -------------------------------------------------------
152
+ # TEMPLATE / ADAPTIVE CACHE — runtime state, not source
153
+ # -------------------------------------------------------
154
+ universal_parser/adaptive/templates/
155
+ templates/
156
+
157
+ # -------------------------------------------------------
158
+ # LARGE TEST FIXTURES — keep small samples, not real docs
159
+ # -------------------------------------------------------
160
+ # Uncomment if you have large fixture files you do not want pushed
161
+ # tests/fixtures/**/*.large.pdf
@@ -0,0 +1 @@
1
+ 3.11
@@ -0,0 +1,78 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.0.0] - 2026-09-08
9
+
10
+ ### Added
11
+ - Multi-Model LLM Benchmark Hub supporting 15 frontier and open-weight models across Google Gemini, OpenAI GPT-4o, Anthropic Claude, DeepSeek, Alibaba Qwen, Meta Llama, Mistral AI, Moonshot Kimi, Zhipu GLM, and Cohere.
12
+ - Full multi-OS (Ubuntu, macOS, Windows) and multi-Python (3.10, 3.11, 3.12) GitHub Actions CI/CD matrix.
13
+ - Automated PyPI publishing workflow on tagged releases.
14
+ - Comprehensive production documentation, quickstart examples, architecture specifications, and benchmark comparison matrices in README.md.
15
+
16
+ ## [0.11.0] - 2026-09-08
17
+
18
+ ### Added
19
+ - Multi-model LLM benchmarking engine supporting live Google Gemini API and OpenRouter API connections with automated offline simulation fallback.
20
+ - Real-time observability telemetry system (`MetricsCollector`) tracking ingestion latency, page volume, element counts, and anomaly markers.
21
+ - Standalone interactive HTML/CSS telemetry and drift dashboard export (`export_dashboard()`).
22
+
23
+ ## [0.10.0] - 2026-09-08
24
+
25
+ ### Added
26
+ - Content-agnostic 2D spatial histogram discretization ($10 \times 10$ grid) for layout fingerprinting.
27
+ - Hybrid Cosine-Jaccard layout similarity scoring engine.
28
+ - Thread-safe LRU template configuration cache with exact SHA-256 and fuzzy matching persistence.
29
+ - Coordinate-descent heuristic auto-tuning optimizer with mathematical guardrails.
30
+
31
+ ## [0.9.0] - 2026-09-08
32
+
33
+ ### Added
34
+ - FastMCP server implementation over stdio protocol exposing `parse_document` and `list_supported_formats`.
35
+
36
+ ## [0.8.0] - 2026-09-08
37
+
38
+ ### Added
39
+ - Downstream RAG exports: clean Markdown formatter, hierarchical chunking with parent-heading breadcrumb context injection, and Graphviz/NetworkX knowledge graph export.
40
+
41
+ ## [0.7.0] - 2026-09-08
42
+
43
+ ### Added
44
+ - Generator-driven streaming pipeline and memory profiling verifying strictly under 250 MB RSS footprint across 1,000+ page documents.
45
+
46
+ ## [0.6.0] - 2026-09-08
47
+
48
+ ### Added
49
+ - OLE compound binary format extractor for legacy `.doc`, `.xls`, `.ppt` files with recursive embedded asset unpacking.
50
+ - PowerPoint `.pptx` slide shape, table, and hierarchy parser.
51
+
52
+ ## [0.5.0] - 2026-09-08
53
+
54
+ ### Added
55
+ - Email parser for `.eml`, `.msg`, and `.mbox` formats with recursive attachment extraction and routing.
56
+
57
+ ## [0.4.0] - 2026-09-08
58
+
59
+ ### Added
60
+ - Optical Character Recognition (OCR) module with RapidOCR (ONNXRuntime CPU) and OpenCV auto-orientation, deskew, and preprocessing.
61
+
62
+ ## [0.3.0] - 2026-09-08
63
+
64
+ ### Added
65
+ - Web and structured data extractors: HTML/XHTML via `selectolax`, EPUB, CSV/TSV with dialect auto-detection, columnar Parquet via `pyarrow`, and JSON/XML.
66
+
67
+ ## [0.2.0] - 2026-09-08
68
+
69
+ ### Added
70
+ - Dual-mode table extraction: Lattice and Stream table extraction with cell-density and dimensional boundary constraints.
71
+
72
+ ## [0.1.0] - 2026-09-08
73
+
74
+ ### Added
75
+ - Core architecture: magic-byte sniffing, extractor routing registry, and unified Pydantic schema.
76
+ - Native PDF extraction via `pypdfium2` with multi-column clustering and font-size percentile heading hierarchy.
77
+ - Word `.docx` and Excel `.xlsx` streaming extractors.
78
+ - Complete replacement of AGPL dependencies with 100% permissively licensed components.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Karan Shelar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.