gleanly 0.1.0a1__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.
- gleanly-0.1.0a1/.gitignore +15 -0
- gleanly-0.1.0a1/CHANGELOG.md +36 -0
- gleanly-0.1.0a1/CONTRIBUTING.md +50 -0
- gleanly-0.1.0a1/LICENSE +202 -0
- gleanly-0.1.0a1/PKG-INFO +167 -0
- gleanly-0.1.0a1/README.md +128 -0
- gleanly-0.1.0a1/SECURITY.md +27 -0
- gleanly-0.1.0a1/bench/README.md +377 -0
- gleanly-0.1.0a1/bench/__init__.py +0 -0
- gleanly-0.1.0a1/bench/confidence.py +138 -0
- gleanly-0.1.0a1/bench/datasets.py +212 -0
- gleanly-0.1.0a1/bench/extractors.py +77 -0
- gleanly-0.1.0a1/bench/metrics.py +64 -0
- gleanly-0.1.0a1/bench/ocr.py +375 -0
- gleanly-0.1.0a1/bench/ocr_hard.py +146 -0
- gleanly-0.1.0a1/bench/run.py +153 -0
- gleanly-0.1.0a1/docs/architecture.md +57 -0
- gleanly-0.1.0a1/docs/dependencies.md +72 -0
- gleanly-0.1.0a1/docs/review.md +72 -0
- gleanly-0.1.0a1/docs/roadmap.md +103 -0
- gleanly-0.1.0a1/docs/status.md +60 -0
- gleanly-0.1.0a1/docs/versioning.md +35 -0
- gleanly-0.1.0a1/pyproject.toml +115 -0
- gleanly-0.1.0a1/src/gleanly/__about__.py +1 -0
- gleanly-0.1.0a1/src/gleanly/__init__.py +62 -0
- gleanly-0.1.0a1/src/gleanly/clean/__init__.py +15 -0
- gleanly-0.1.0a1/src/gleanly/clean/blocks.py +201 -0
- gleanly-0.1.0a1/src/gleanly/clean/comments.py +98 -0
- gleanly-0.1.0a1/src/gleanly/clean/html.py +773 -0
- gleanly-0.1.0a1/src/gleanly/clean/metadata.py +110 -0
- gleanly-0.1.0a1/src/gleanly/cli.py +174 -0
- gleanly-0.1.0a1/src/gleanly/client.py +791 -0
- gleanly-0.1.0a1/src/gleanly/compliance/__init__.py +15 -0
- gleanly-0.1.0a1/src/gleanly/compliance/aitxt.py +139 -0
- gleanly-0.1.0a1/src/gleanly/compliance/assess.py +136 -0
- gleanly-0.1.0a1/src/gleanly/compliance/license.py +93 -0
- gleanly-0.1.0a1/src/gleanly/compliance/pii.py +51 -0
- gleanly-0.1.0a1/src/gleanly/compliance/tdmrep.py +120 -0
- gleanly-0.1.0a1/src/gleanly/config.py +63 -0
- gleanly-0.1.0a1/src/gleanly/errors.py +31 -0
- gleanly-0.1.0a1/src/gleanly/fetch/__init__.py +9 -0
- gleanly-0.1.0a1/src/gleanly/fetch/browser.py +50 -0
- gleanly-0.1.0a1/src/gleanly/fetch/embedded.py +108 -0
- gleanly-0.1.0a1/src/gleanly/fetch/http.py +110 -0
- gleanly-0.1.0a1/src/gleanly/fetch/ratelimit.py +33 -0
- gleanly-0.1.0a1/src/gleanly/fetch/robots.py +111 -0
- gleanly-0.1.0a1/src/gleanly/fetch/router.py +35 -0
- gleanly-0.1.0a1/src/gleanly/loader.py +33 -0
- gleanly-0.1.0a1/src/gleanly/models.py +303 -0
- gleanly-0.1.0a1/src/gleanly/ocr/__init__.py +1 -0
- gleanly-0.1.0a1/src/gleanly/ocr/engine.py +66 -0
- gleanly-0.1.0a1/src/gleanly/ocr/preprocess.py +144 -0
- gleanly-0.1.0a1/src/gleanly/ocr/tesseract.py +162 -0
- gleanly-0.1.0a1/src/gleanly/pdf/__init__.py +5 -0
- gleanly-0.1.0a1/src/gleanly/pdf/check.py +113 -0
- gleanly-0.1.0a1/src/gleanly/pdf/layout.py +298 -0
- gleanly-0.1.0a1/src/gleanly/pdf/native.py +261 -0
- gleanly-0.1.0a1/src/gleanly/py.typed +0 -0
- gleanly-0.1.0a1/src/gleanly/quality/__init__.py +129 -0
- gleanly-0.1.0a1/src/gleanly/quality/crosscheck.py +102 -0
- gleanly-0.1.0a1/src/gleanly/search/__init__.py +209 -0
- gleanly-0.1.0a1/src/gleanly/search/agreement.py +287 -0
- gleanly-0.1.0a1/src/gleanly/search/backends.py +186 -0
- gleanly-0.1.0a1/src/gleanly/search/fusion.py +57 -0
- gleanly-0.1.0a1/tests/__init__.py +0 -0
- gleanly-0.1.0a1/tests/conftest.py +28 -0
- gleanly-0.1.0a1/tests/fixtures/article.html +48 -0
- gleanly-0.1.0a1/tests/fixtures/jsonld_article.html +16 -0
- gleanly-0.1.0a1/tests/fixtures/realworld/blog_comments.expected.md +17 -0
- gleanly-0.1.0a1/tests/fixtures/realworld/blog_comments.html +78 -0
- gleanly-0.1.0a1/tests/fixtures/realworld/docs.expected.md +30 -0
- gleanly-0.1.0a1/tests/fixtures/realworld/docs.html +69 -0
- gleanly-0.1.0a1/tests/fixtures/realworld/news.expected.md +19 -0
- gleanly-0.1.0a1/tests/fixtures/realworld/news.html +90 -0
- gleanly-0.1.0a1/tests/fixtures/realworld/product.expected.md +18 -0
- gleanly-0.1.0a1/tests/fixtures/realworld/product.html +53 -0
- gleanly-0.1.0a1/tests/fixtures/spa_next.html +16 -0
- gleanly-0.1.0a1/tests/pdfmaker.py +164 -0
- gleanly-0.1.0a1/tests/test_agreement.py +97 -0
- gleanly-0.1.0a1/tests/test_bench_metrics.py +94 -0
- gleanly-0.1.0a1/tests/test_blocks.py +75 -0
- gleanly-0.1.0a1/tests/test_client.py +341 -0
- gleanly-0.1.0a1/tests/test_comments.py +82 -0
- gleanly-0.1.0a1/tests/test_compliance.py +266 -0
- gleanly-0.1.0a1/tests/test_crosscheck.py +107 -0
- gleanly-0.1.0a1/tests/test_embedded_and_router.py +62 -0
- gleanly-0.1.0a1/tests/test_extraction.py +176 -0
- gleanly-0.1.0a1/tests/test_fetch.py +126 -0
- gleanly-0.1.0a1/tests/test_ocr.py +190 -0
- gleanly-0.1.0a1/tests/test_pdf.py +185 -0
- gleanly-0.1.0a1/tests/test_quality_and_cli.py +88 -0
- gleanly-0.1.0a1/tests/test_realworld.py +130 -0
- gleanly-0.1.0a1/tests/test_search.py +205 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to gleanly are listed here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow
|
|
5
|
+
[Semantic Versioning](https://semver.org/) as described in [docs/versioning.md](docs/versioning.md).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [0.1.0a1] - 2026-11-22
|
|
10
|
+
|
|
11
|
+
First public alpha.
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- `load()` / `aload()` / `Client`: URLs and local files to clean Markdown with metadata,
|
|
16
|
+
a trust score (`QualityReport`), AI-use compliance evidence (`ComplianceInfo`) and
|
|
17
|
+
block-level provenance.
|
|
18
|
+
- Ethical fetch ladder: plain HTTP with an honest User-Agent, embedded data (JSON-LD,
|
|
19
|
+
`__NEXT_DATA__`), optional Playwright rendering (`[browser]`); robots.txt, Crawl-delay and
|
|
20
|
+
per-host rate limits.
|
|
21
|
+
- Main-content extraction with an independent cross-check: `extraction_confidence`,
|
|
22
|
+
`extraction_support`, `extraction_coverage`, per-block `support`; optional reader
|
|
23
|
+
comments (`include_comments`).
|
|
24
|
+
- Compliance evidence: robots.txt and AI-crawler opt-outs, TDMRep, ai.txt, `noai`,
|
|
25
|
+
license detection, PII flags; verdict `ai_use` with `conditions` and a disclaimer.
|
|
26
|
+
- PDFs (`[pdf]`): headings, lists, de-hyphenation, running headers removed, page and
|
|
27
|
+
bounding-box provenance; text layer checked against OCR.
|
|
28
|
+
- OCR (`[ocr]` + Tesseract): images, image URLs and scanned PDF pages, with background
|
|
29
|
+
flattening and text-size normalisation; `ocr_confidence` in the trust score.
|
|
30
|
+
- `search()` / `asearch()`: Wikipedia, Brave and SearXNG backends (official APIs only),
|
|
31
|
+
reciprocal rank fusion, every result fetched and scored.
|
|
32
|
+
- Search agreement (experimental): `SearchResponse.agreement` with corroborated and
|
|
33
|
+
conflicting numeric/date facts, each source quoted with its location.
|
|
34
|
+
- CLI: `gleanly load` and `gleanly search`.
|
|
35
|
+
- Benchmarks (`bench/`): web extraction on 8 datasets, OCR standard and hard suites,
|
|
36
|
+
confidence calibration.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Contributing to gleanly
|
|
2
|
+
|
|
3
|
+
Thanks for helping. This guide gets you from a fresh clone to a merged change.
|
|
4
|
+
|
|
5
|
+
## Set up
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
git clone https://github.com/JordanManoj/gleanly.git
|
|
9
|
+
cd gleanly
|
|
10
|
+
uv sync --all-extras --all-groups # installs dev tools, the [pdf]/[ocr]/[browser] extras and bench baselines
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
OCR tests also need the [Tesseract](https://github.com/tesseract-ocr/tesseract) program;
|
|
14
|
+
without it they are skipped.
|
|
15
|
+
|
|
16
|
+
## Before you open a pull request
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
uv run ruff format . # formatting (also checks code examples in Markdown)
|
|
20
|
+
uv run ruff check . # lint
|
|
21
|
+
uv run pyright # types
|
|
22
|
+
uv run pytest # tests (no real network: HTTP is mocked)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
CI runs the same checks on Linux, macOS and Windows with Python 3.10-3.13.
|
|
26
|
+
|
|
27
|
+
## What a good change looks like
|
|
28
|
+
|
|
29
|
+
- **One topic per pull request**, with tests. Unit tests never touch the real network:
|
|
30
|
+
mock HTTP with `respx`, and generate test documents (see `tests/pdfmaker.py`).
|
|
31
|
+
- **Accuracy changes come with numbers.** If you change extraction, OCR or ranking, run
|
|
32
|
+
the matching benchmark (`bench/`), tune only on the `dev` split and report the `test`
|
|
33
|
+
split in the pull request. Changes that do not beat the current results on `test` are
|
|
34
|
+
not merged; record them under "tried and dropped" in `bench/README.md` instead.
|
|
35
|
+
- **New dependencies** must have a permissive license (MIT, BSD, Apache-2.0, ...), be
|
|
36
|
+
listed in `docs/dependencies.md`, and go into an optional extra if they are heavy.
|
|
37
|
+
- **Ethical fetching** is not negotiable: no anti-bot evasion, honest User-Agent,
|
|
38
|
+
robots.txt respected by default.
|
|
39
|
+
- Update `CHANGELOG.md` under "Unreleased".
|
|
40
|
+
|
|
41
|
+
## Where things are
|
|
42
|
+
|
|
43
|
+
See [docs/architecture.md](docs/architecture.md) for how a `load()` call flows through the
|
|
44
|
+
code, and [docs/roadmap.md](docs/roadmap.md) and [docs/review.md](docs/review.md) for what
|
|
45
|
+
is planned and the known weaknesses (good places to start).
|
|
46
|
+
|
|
47
|
+
## Reporting bugs
|
|
48
|
+
|
|
49
|
+
Open an issue with the gleanly version, the source (URL or a small file) and what you
|
|
50
|
+
expected. Security problems: see [SECURITY.md](SECURITY.md).
|
gleanly-0.1.0a1/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
gleanly-0.1.0a1/PKG-INFO
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: gleanly
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: All-in-one text acquisition for AI: scraping, OCR and search with trust scores, compliance metadata and provenance.
|
|
5
|
+
Project-URL: Homepage, https://github.com/JordanManoj/gleanly
|
|
6
|
+
Project-URL: Source, https://github.com/JordanManoj/gleanly
|
|
7
|
+
Project-URL: Issues, https://github.com/JordanManoj/gleanly/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/JordanManoj/gleanly/blob/main/CHANGELOG.md
|
|
9
|
+
Project-URL: Benchmarks, https://github.com/JordanManoj/gleanly/blob/main/bench/README.md
|
|
10
|
+
Author: Jordan Manoj
|
|
11
|
+
License-Expression: Apache-2.0
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: compliance,llm,markdown,ocr,provenance,rag,scraping,search
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search
|
|
24
|
+
Classifier: Topic :: Text Processing :: Markup :: HTML
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: >=3.10
|
|
27
|
+
Requires-Dist: httpx>=0.27
|
|
28
|
+
Requires-Dist: lxml>=5.2
|
|
29
|
+
Requires-Dist: protego>=0.3
|
|
30
|
+
Requires-Dist: pydantic>=2.7
|
|
31
|
+
Provides-Extra: browser
|
|
32
|
+
Requires-Dist: playwright>=1.45; extra == 'browser'
|
|
33
|
+
Provides-Extra: ocr
|
|
34
|
+
Requires-Dist: pillow>=10.0; extra == 'ocr'
|
|
35
|
+
Requires-Dist: pypdfium2>=4.30; extra == 'ocr'
|
|
36
|
+
Provides-Extra: pdf
|
|
37
|
+
Requires-Dist: pypdfium2>=4.30; extra == 'pdf'
|
|
38
|
+
Description-Content-Type: text/markdown
|
|
39
|
+
|
|
40
|
+
# gleanly
|
|
41
|
+
|
|
42
|
+
**All-in-one, open-source text acquisition for AI.** Turn any URL or file into clean
|
|
43
|
+
Markdown with a **trust score**, **compliance metadata** ("can I use this for AI
|
|
44
|
+
training?") and **provenance** for every block. One `pip install`, one process, no Docker.
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pip install --pre gleanly # alpha: --pre is needed until 1.0
|
|
48
|
+
pip install --pre "gleanly[pdf,ocr]" # + PDFs and OCR (OCR also needs Tesseract installed)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
> **Alpha:** the API may still change between 0.x releases (see the
|
|
52
|
+
> [versioning policy](https://github.com/JordanManoj/gleanly/blob/main/docs/versioning.md)).
|
|
53
|
+
> Feedback and bug reports are very welcome.
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from gleanly import load
|
|
57
|
+
|
|
58
|
+
doc = load("https://example.com/article")
|
|
59
|
+
print(doc.markdown) # clean Markdown (tables and code preserved)
|
|
60
|
+
print(doc.quality.score) # 0..1, comparable across web, PDF and OCR sources
|
|
61
|
+
print(doc.compliance.ai_use) # "allowed" | "disallowed" | "unclear" + conditions and evidence
|
|
62
|
+
print(doc.blocks[0].provenance) # URL + XPath + character span in the Markdown
|
|
63
|
+
print(doc.fetch_trace.steps) # every fetch-ladder step that was tried, and why
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Async: `doc = await aload(url)`. Batch with shared rate limits: `async with Client() as c: ...`
|
|
67
|
+
|
|
68
|
+
CLI:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
gleanly load https://example.com/article -o article.md
|
|
72
|
+
gleanly load https://example.com/article -o article.json # full Document as JSON
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## PDFs, scans and images
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pip install "gleanly[pdf]" # native PDFs
|
|
79
|
+
pip install "gleanly[ocr]" # + OCR; also install Tesseract (github.com/tesseract-ocr/tesseract)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
doc = load("report.pdf") # or "scan.jpg", or a URL serving either
|
|
84
|
+
doc.blocks[3].provenance # kind="pdf" (text layer) or "image" (OCR), page, bbox
|
|
85
|
+
doc.quality.ocr_confidence # Tesseract's word confidence, when OCR was used
|
|
86
|
+
doc.quality.extraction_confidence # PDFs: agreement between the text layer and OCR
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
What gleanly adds on top of plain PDF text extraction and Tesseract:
|
|
90
|
+
|
|
91
|
+
- Headings, lists and re-joined hyphenation; running headers, footers and page numbers
|
|
92
|
+
learned across pages and removed.
|
|
93
|
+
- Scanned pages inside a PDF are OCR'd automatically.
|
|
94
|
+
- **Text-layer check:** pages whose hidden text looks broken, plus a small sample, are
|
|
95
|
+
compared with OCR; a layer that does not match the page (a wrong font map, a poor old
|
|
96
|
+
OCR layer) is replaced and the page is named in a warning.
|
|
97
|
+
- OCR clean-up tuned on a benchmark: 0.77% characters wrong on held-out pages against
|
|
98
|
+
16.1% for plain Tesseract, mostly by fixing shadows, faint print and phone photos
|
|
99
|
+
([bench/README.md](https://github.com/JordanManoj/gleanly/blob/main/bench/README.md)).
|
|
100
|
+
|
|
101
|
+
## Search
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from gleanly import search
|
|
105
|
+
|
|
106
|
+
resp = search("tide pool animals") # Wikipedia by default; Brave/SearXNG when configured
|
|
107
|
+
for r in resp.results:
|
|
108
|
+
print(r.score, r.hit.url, r.hit.engines) # which engines found it, and at what rank
|
|
109
|
+
print(r.document.quality.score, r.document.compliance.ai_use) # every result is a full Document
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
gleanly search "tide pool animals" -n 5 --exclude-disallowed
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Backends use official APIs only: Wikipedia (no key), Brave Search (`BRAVE_API_KEY`) and
|
|
117
|
+
your own SearXNG instance (`SEARXNG_URL`). Results from several engines are merged with
|
|
118
|
+
reciprocal rank fusion, then every page is fetched through `load()` (robots.txt, rate
|
|
119
|
+
limits, trust score, AI-use verdict, provenance). Ranking v0 combines query relevance,
|
|
120
|
+
the fused rank and the page's trust score; it will be tuned on a search benchmark.
|
|
121
|
+
|
|
122
|
+
**Source agreement (experimental):** `resp.agreement` lists numeric and date facts that
|
|
123
|
+
two or more results agree on (`corroborated`) or contradict (`conflicts`), each quoting
|
|
124
|
+
every source with its exact location. It is strict on purpose (a conflict needs nearly
|
|
125
|
+
the same sentence with a different number) and reports candidates to check, not verdicts.
|
|
126
|
+
|
|
127
|
+
## Status
|
|
128
|
+
|
|
129
|
+
Phases 1 (web pages) and 2 (PDFs and OCR) are done; Phase 3 (search) is in progress. See
|
|
130
|
+
[docs/status.md](https://github.com/JordanManoj/gleanly/blob/main/docs/status.md).
|
|
131
|
+
|
|
132
|
+
| Capability | Status |
|
|
133
|
+
| --- | --- |
|
|
134
|
+
| Web page → Markdown + metadata | ✅ v0 |
|
|
135
|
+
| Fetch ladder: HTTP → embedded data (JSON-LD, `__NEXT_DATA__`) → Playwright | ✅ v0 |
|
|
136
|
+
| robots.txt (RFC 9309), per-host rate limiting, honest User-Agent | ✅ |
|
|
137
|
+
| Compliance: TDMRep, `ai.txt`, `noai`, AI-crawler opt-outs, license detection, PII flags | ✅ v0 |
|
|
138
|
+
| Quality report + trust score | ✅ v0 (uncalibrated) |
|
|
139
|
+
| Native PDFs (`gleanly[pdf]`): headings, lists, page + bounding-box provenance, running headers removed | ✅ v0 |
|
|
140
|
+
| OCR for images and scanned PDF pages (`gleanly[ocr]` + Tesseract): background flattening, text-size normalisation, layout self-check, OCR confidence in the trust score | ✅ v0 |
|
|
141
|
+
| `search()` with reranking and cross-source agreement | Phase 3 |
|
|
142
|
+
| Archive fallbacks, crawling, server mode, benchmark | Phase 4 |
|
|
143
|
+
|
|
144
|
+
## Ethics by design
|
|
145
|
+
|
|
146
|
+
The library identifies itself honestly (`gleanly/<version> (+project URL)`), respects
|
|
147
|
+
robots.txt by default, rate-limits per host and never tries to evade blocks: no fingerprint
|
|
148
|
+
spoofing, CAPTCHA solving or proxy rotation. When a site refuses access, you get a clear
|
|
149
|
+
explanation in `FetchError.trace`.
|
|
150
|
+
|
|
151
|
+
## Install (development)
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
uv sync # core + dev tools
|
|
155
|
+
uv run pytest
|
|
156
|
+
uv sync --extra browser && uv run playwright install chromium # optional rung 3
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## License
|
|
160
|
+
|
|
161
|
+
Apache-2.0
|
|
162
|
+
|
|
163
|
+
## Contributing and security
|
|
164
|
+
|
|
165
|
+
See [CONTRIBUTING.md](https://github.com/JordanManoj/gleanly/blob/main/CONTRIBUTING.md), [docs/architecture.md](https://github.com/JordanManoj/gleanly/blob/main/docs/architecture.md),
|
|
166
|
+
[SECURITY.md](https://github.com/JordanManoj/gleanly/blob/main/SECURITY.md) and the [CHANGELOG](https://github.com/JordanManoj/gleanly/blob/main/CHANGELOG.md).
|
|
167
|
+
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# gleanly
|
|
2
|
+
|
|
3
|
+
**All-in-one, open-source text acquisition for AI.** Turn any URL or file into clean
|
|
4
|
+
Markdown with a **trust score**, **compliance metadata** ("can I use this for AI
|
|
5
|
+
training?") and **provenance** for every block. One `pip install`, one process, no Docker.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install --pre gleanly # alpha: --pre is needed until 1.0
|
|
9
|
+
pip install --pre "gleanly[pdf,ocr]" # + PDFs and OCR (OCR also needs Tesseract installed)
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
> **Alpha:** the API may still change between 0.x releases (see the
|
|
13
|
+
> [versioning policy](https://github.com/JordanManoj/gleanly/blob/main/docs/versioning.md)).
|
|
14
|
+
> Feedback and bug reports are very welcome.
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
from gleanly import load
|
|
18
|
+
|
|
19
|
+
doc = load("https://example.com/article")
|
|
20
|
+
print(doc.markdown) # clean Markdown (tables and code preserved)
|
|
21
|
+
print(doc.quality.score) # 0..1, comparable across web, PDF and OCR sources
|
|
22
|
+
print(doc.compliance.ai_use) # "allowed" | "disallowed" | "unclear" + conditions and evidence
|
|
23
|
+
print(doc.blocks[0].provenance) # URL + XPath + character span in the Markdown
|
|
24
|
+
print(doc.fetch_trace.steps) # every fetch-ladder step that was tried, and why
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Async: `doc = await aload(url)`. Batch with shared rate limits: `async with Client() as c: ...`
|
|
28
|
+
|
|
29
|
+
CLI:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
gleanly load https://example.com/article -o article.md
|
|
33
|
+
gleanly load https://example.com/article -o article.json # full Document as JSON
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## PDFs, scans and images
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install "gleanly[pdf]" # native PDFs
|
|
40
|
+
pip install "gleanly[ocr]" # + OCR; also install Tesseract (github.com/tesseract-ocr/tesseract)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
doc = load("report.pdf") # or "scan.jpg", or a URL serving either
|
|
45
|
+
doc.blocks[3].provenance # kind="pdf" (text layer) or "image" (OCR), page, bbox
|
|
46
|
+
doc.quality.ocr_confidence # Tesseract's word confidence, when OCR was used
|
|
47
|
+
doc.quality.extraction_confidence # PDFs: agreement between the text layer and OCR
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
What gleanly adds on top of plain PDF text extraction and Tesseract:
|
|
51
|
+
|
|
52
|
+
- Headings, lists and re-joined hyphenation; running headers, footers and page numbers
|
|
53
|
+
learned across pages and removed.
|
|
54
|
+
- Scanned pages inside a PDF are OCR'd automatically.
|
|
55
|
+
- **Text-layer check:** pages whose hidden text looks broken, plus a small sample, are
|
|
56
|
+
compared with OCR; a layer that does not match the page (a wrong font map, a poor old
|
|
57
|
+
OCR layer) is replaced and the page is named in a warning.
|
|
58
|
+
- OCR clean-up tuned on a benchmark: 0.77% characters wrong on held-out pages against
|
|
59
|
+
16.1% for plain Tesseract, mostly by fixing shadows, faint print and phone photos
|
|
60
|
+
([bench/README.md](https://github.com/JordanManoj/gleanly/blob/main/bench/README.md)).
|
|
61
|
+
|
|
62
|
+
## Search
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from gleanly import search
|
|
66
|
+
|
|
67
|
+
resp = search("tide pool animals") # Wikipedia by default; Brave/SearXNG when configured
|
|
68
|
+
for r in resp.results:
|
|
69
|
+
print(r.score, r.hit.url, r.hit.engines) # which engines found it, and at what rank
|
|
70
|
+
print(r.document.quality.score, r.document.compliance.ai_use) # every result is a full Document
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
gleanly search "tide pool animals" -n 5 --exclude-disallowed
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Backends use official APIs only: Wikipedia (no key), Brave Search (`BRAVE_API_KEY`) and
|
|
78
|
+
your own SearXNG instance (`SEARXNG_URL`). Results from several engines are merged with
|
|
79
|
+
reciprocal rank fusion, then every page is fetched through `load()` (robots.txt, rate
|
|
80
|
+
limits, trust score, AI-use verdict, provenance). Ranking v0 combines query relevance,
|
|
81
|
+
the fused rank and the page's trust score; it will be tuned on a search benchmark.
|
|
82
|
+
|
|
83
|
+
**Source agreement (experimental):** `resp.agreement` lists numeric and date facts that
|
|
84
|
+
two or more results agree on (`corroborated`) or contradict (`conflicts`), each quoting
|
|
85
|
+
every source with its exact location. It is strict on purpose (a conflict needs nearly
|
|
86
|
+
the same sentence with a different number) and reports candidates to check, not verdicts.
|
|
87
|
+
|
|
88
|
+
## Status
|
|
89
|
+
|
|
90
|
+
Phases 1 (web pages) and 2 (PDFs and OCR) are done; Phase 3 (search) is in progress. See
|
|
91
|
+
[docs/status.md](https://github.com/JordanManoj/gleanly/blob/main/docs/status.md).
|
|
92
|
+
|
|
93
|
+
| Capability | Status |
|
|
94
|
+
| --- | --- |
|
|
95
|
+
| Web page → Markdown + metadata | ✅ v0 |
|
|
96
|
+
| Fetch ladder: HTTP → embedded data (JSON-LD, `__NEXT_DATA__`) → Playwright | ✅ v0 |
|
|
97
|
+
| robots.txt (RFC 9309), per-host rate limiting, honest User-Agent | ✅ |
|
|
98
|
+
| Compliance: TDMRep, `ai.txt`, `noai`, AI-crawler opt-outs, license detection, PII flags | ✅ v0 |
|
|
99
|
+
| Quality report + trust score | ✅ v0 (uncalibrated) |
|
|
100
|
+
| Native PDFs (`gleanly[pdf]`): headings, lists, page + bounding-box provenance, running headers removed | ✅ v0 |
|
|
101
|
+
| OCR for images and scanned PDF pages (`gleanly[ocr]` + Tesseract): background flattening, text-size normalisation, layout self-check, OCR confidence in the trust score | ✅ v0 |
|
|
102
|
+
| `search()` with reranking and cross-source agreement | Phase 3 |
|
|
103
|
+
| Archive fallbacks, crawling, server mode, benchmark | Phase 4 |
|
|
104
|
+
|
|
105
|
+
## Ethics by design
|
|
106
|
+
|
|
107
|
+
The library identifies itself honestly (`gleanly/<version> (+project URL)`), respects
|
|
108
|
+
robots.txt by default, rate-limits per host and never tries to evade blocks: no fingerprint
|
|
109
|
+
spoofing, CAPTCHA solving or proxy rotation. When a site refuses access, you get a clear
|
|
110
|
+
explanation in `FetchError.trace`.
|
|
111
|
+
|
|
112
|
+
## Install (development)
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
uv sync # core + dev tools
|
|
116
|
+
uv run pytest
|
|
117
|
+
uv sync --extra browser && uv run playwright install chromium # optional rung 3
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## License
|
|
121
|
+
|
|
122
|
+
Apache-2.0
|
|
123
|
+
|
|
124
|
+
## Contributing and security
|
|
125
|
+
|
|
126
|
+
See [CONTRIBUTING.md](https://github.com/JordanManoj/gleanly/blob/main/CONTRIBUTING.md), [docs/architecture.md](https://github.com/JordanManoj/gleanly/blob/main/docs/architecture.md),
|
|
127
|
+
[SECURITY.md](https://github.com/JordanManoj/gleanly/blob/main/SECURITY.md) and the [CHANGELOG](https://github.com/JordanManoj/gleanly/blob/main/CHANGELOG.md).
|
|
128
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Security policy
|
|
2
|
+
|
|
3
|
+
## Supported versions
|
|
4
|
+
|
|
5
|
+
gleanly is in alpha. Security fixes go into the latest release only.
|
|
6
|
+
|
|
7
|
+
## Reporting a vulnerability
|
|
8
|
+
|
|
9
|
+
Please do **not** open a public issue for security problems. Use GitHub's private
|
|
10
|
+
vulnerability reporting instead: open the repository's **Security** tab and choose
|
|
11
|
+
**Report a vulnerability**. You can expect a first answer within 7 days.
|
|
12
|
+
|
|
13
|
+
Useful details: the gleanly version, a minimal input (URL, HTML, PDF or image) that
|
|
14
|
+
triggers the problem, and what happens.
|
|
15
|
+
|
|
16
|
+
## What gleanly treats as untrusted
|
|
17
|
+
|
|
18
|
+
Everything it fetches or opens: web pages, PDFs, images, robots.txt, ai.txt, TDMRep
|
|
19
|
+
files and search results. gleanly parses this input but never executes it; JavaScript
|
|
20
|
+
only runs inside the optional Playwright browser (`[browser]` extra), in its sandbox.
|
|
21
|
+
Size limits (`max_bytes`) and timeouts apply to every download.
|
|
22
|
+
|
|
23
|
+
## How dependencies are checked
|
|
24
|
+
|
|
25
|
+
CI audits the locked dependencies for known vulnerabilities on every push
|
|
26
|
+
(`pip-audit`), and new dependencies are license- and maintenance-checked before they are
|
|
27
|
+
added (see [docs/dependencies.md](docs/dependencies.md)).
|