any2llm 0.2.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.
- any2llm-0.2.0/LICENSE +21 -0
- any2llm-0.2.0/PKG-INFO +49 -0
- any2llm-0.2.0/README.md +126 -0
- any2llm-0.2.0/docs/pypi.md +11 -0
- any2llm-0.2.0/pyproject.toml +56 -0
- any2llm-0.2.0/setup.cfg +4 -0
- any2llm-0.2.0/src/any2llm/__init__.py +0 -0
- any2llm-0.2.0/src/any2llm/__main__.py +6 -0
- any2llm-0.2.0/src/any2llm/cleaner.py +38 -0
- any2llm-0.2.0/src/any2llm/cli.py +361 -0
- any2llm-0.2.0/src/any2llm/clipboard.py +28 -0
- any2llm-0.2.0/src/any2llm/config.py +87 -0
- any2llm-0.2.0/src/any2llm/demo.py +18 -0
- any2llm-0.2.0/src/any2llm/demo_assets/en/measurement-and-bias.pptx +0 -0
- any2llm-0.2.0/src/any2llm/demo_assets/en/measurement-plan.xlsx +0 -0
- any2llm-0.2.0/src/any2llm/demo_assets/en/research-designs.pdf +0 -0
- any2llm-0.2.0/src/any2llm/demo_assets/en/study-checklist.docx +0 -0
- any2llm-0.2.0/src/any2llm/demo_assets/tr/ara/305/237t/304/261rma-desenleri.pdf +0 -0
- any2llm-0.2.0/src/any2llm/demo_assets/tr//303/247al/304/261/305/237ma-listesi.docx +0 -0
- any2llm-0.2.0/src/any2llm/demo_assets/tr//303/266l/303/247/303/274m-plan/304/261.xlsx +0 -0
- any2llm-0.2.0/src/any2llm/demo_assets/tr//303/266l/303/247/303/274m-ve-yanl/304/261l/304/261k.pptx +0 -0
- any2llm-0.2.0/src/any2llm/ignore.py +66 -0
- any2llm-0.2.0/src/any2llm/languages.py +49 -0
- any2llm-0.2.0/src/any2llm/locales/ar.json +128 -0
- any2llm-0.2.0/src/any2llm/locales/bn.json +129 -0
- any2llm-0.2.0/src/any2llm/locales/en.json +128 -0
- any2llm-0.2.0/src/any2llm/locales/es.json +128 -0
- any2llm-0.2.0/src/any2llm/locales/fr.json +128 -0
- any2llm-0.2.0/src/any2llm/locales/hi.json +129 -0
- any2llm-0.2.0/src/any2llm/locales/pt.json +128 -0
- any2llm-0.2.0/src/any2llm/locales/ru.json +128 -0
- any2llm-0.2.0/src/any2llm/locales/tr.json +128 -0
- any2llm-0.2.0/src/any2llm/locales/ur.json +128 -0
- any2llm-0.2.0/src/any2llm/locales/zh.json +128 -0
- any2llm-0.2.0/src/any2llm/messages.py +23 -0
- any2llm-0.2.0/src/any2llm/ocr.py +47 -0
- any2llm-0.2.0/src/any2llm/output.py +131 -0
- any2llm-0.2.0/src/any2llm/packer.py +224 -0
- any2llm-0.2.0/src/any2llm/parse_worker.py +75 -0
- any2llm-0.2.0/src/any2llm/parsers.py +340 -0
- any2llm-0.2.0/src/any2llm/prompts.py +32 -0
- any2llm-0.2.0/src/any2llm/scanner.py +122 -0
- any2llm-0.2.0/src/any2llm/secrets.py +19 -0
- any2llm-0.2.0/src/any2llm/terminal.py +228 -0
- any2llm-0.2.0/src/any2llm/tokenizer.py +21 -0
- any2llm-0.2.0/src/any2llm/tools.py +32 -0
- any2llm-0.2.0/src/any2llm.egg-info/PKG-INFO +49 -0
- any2llm-0.2.0/src/any2llm.egg-info/SOURCES.txt +65 -0
- any2llm-0.2.0/src/any2llm.egg-info/dependency_links.txt +1 -0
- any2llm-0.2.0/src/any2llm.egg-info/entry_points.txt +2 -0
- any2llm-0.2.0/src/any2llm.egg-info/requires.txt +13 -0
- any2llm-0.2.0/src/any2llm.egg-info/top_level.txt +1 -0
- any2llm-0.2.0/tests/test_cleaner.py +21 -0
- any2llm-0.2.0/tests/test_cli.py +440 -0
- any2llm-0.2.0/tests/test_config.py +110 -0
- any2llm-0.2.0/tests/test_localization.py +170 -0
- any2llm-0.2.0/tests/test_ocr.py +50 -0
- any2llm-0.2.0/tests/test_output.py +73 -0
- any2llm-0.2.0/tests/test_packer.py +151 -0
- any2llm-0.2.0/tests/test_parse_worker.py +42 -0
- any2llm-0.2.0/tests/test_parsers.py +337 -0
- any2llm-0.2.0/tests/test_platforms.py +127 -0
- any2llm-0.2.0/tests/test_prompts.py +99 -0
- any2llm-0.2.0/tests/test_scanner.py +179 -0
- any2llm-0.2.0/tests/test_terminal_flow.py +208 -0
- any2llm-0.2.0/tests/test_tokenizer.py +31 -0
- any2llm-0.2.0/tests/test_tools.py +26 -0
any2llm-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ahmet Emre Apo
|
|
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.
|
any2llm-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: any2llm
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Pack mixed documents into Markdown batches for AI chats with original PDF page numbers
|
|
5
|
+
Author: Ahmet Emre Apo
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Repository, https://github.com/ahmetemreapo/any2llm
|
|
8
|
+
Project-URL: Documentation, https://github.com/ahmetemreapo/any2llm/blob/main/docs/SPEC.md
|
|
9
|
+
Project-URL: Issues, https://github.com/ahmetemreapo/any2llm/issues
|
|
10
|
+
Project-URL: Releases, https://github.com/ahmetemreapo/any2llm/releases
|
|
11
|
+
Keywords: pdf,docx,pptx,xlsx,markdown,llm,ocr,document-processing,cli
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Topic :: Text Processing :: Markup :: Markdown
|
|
21
|
+
Classifier: Topic :: Utilities
|
|
22
|
+
Requires-Python: >=3.11
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: pypdf
|
|
26
|
+
Requires-Dist: python-docx>=1.1
|
|
27
|
+
Requires-Dist: python-pptx
|
|
28
|
+
Requires-Dist: openpyxl
|
|
29
|
+
Requires-Dist: defusedxml>=0.7.1
|
|
30
|
+
Requires-Dist: Pillow>=13.0.0
|
|
31
|
+
Requires-Dist: tiktoken
|
|
32
|
+
Requires-Dist: questionary>=2.1
|
|
33
|
+
Requires-Dist: rich
|
|
34
|
+
Requires-Dist: pyperclip
|
|
35
|
+
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: pytest; extra == "dev"
|
|
37
|
+
Dynamic: license-file
|
|
38
|
+
|
|
39
|
+
# any2llm
|
|
40
|
+
|
|
41
|
+
**Ask AI about your documents, then check its PDF citations on the original pages.**
|
|
42
|
+
|
|
43
|
+
any2llm turns a folder of PDF, Word, PowerPoint, Excel, text, and code files into numbered Markdown attachments and a ready-to-paste chat prompt. It keeps physical PDF page numbers and flags pages with missing or partial text so you can check the original.
|
|
44
|
+
|
|
45
|
+
- Set a token budget per batch and use the generated prompt to guide the chat through multiple attachments.
|
|
46
|
+
- Extract text on your computer. Optional OCR for PDF pages without usable text uses Poppler and Tesseract.
|
|
47
|
+
- Choose from 11 languages for terminal output and chat prompts.
|
|
48
|
+
|
|
49
|
+
Requires Python 3.11 or newer. Find examples, usage instructions, and extraction limits in the [GitHub repository](https://github.com/ahmetemreapo/any2llm).
|
any2llm-0.2.0/README.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# any2llm
|
|
2
|
+
|
|
3
|
+
**Ask AI about your documents, then check its PDF citations on the original pages.**
|
|
4
|
+
|
|
5
|
+
any2llm turns a folder of PDF, Word, PowerPoint, Excel, text, and code files into Markdown attachments for an AI chat, with numbered batches and a ready-to-paste prompt.
|
|
6
|
+
|
|
7
|
+
[Türkçe](README.tr.md)
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
[Terminal-only recording](examples/delivery-dates-demo.gif)
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
Requires Python 3.11 or newer, Git, and [pipx](https://pipx.pypa.io/stable/how-to/install-pipx.html).
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
pipx install git+https://github.com/ahmetemreapo/any2llm.git@main
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
[Installation help for Windows, macOS, and Linux](docs/install.md)
|
|
22
|
+
|
|
23
|
+
[](pyproject.toml)
|
|
24
|
+
[](LICENSE)
|
|
25
|
+
[](https://github.com/ahmetemreapo/any2llm/actions/workflows/platforms.yml)
|
|
26
|
+
|
|
27
|
+
## Who is it for?
|
|
28
|
+
|
|
29
|
+
| If you work with… | Try this |
|
|
30
|
+
| --- | --- |
|
|
31
|
+
| Office and finance records | Reconcile dates in a supplier offer and a spreadsheet. See the [delivery dates example](#work-example-delivery-dates). |
|
|
32
|
+
| Legal documents | Compare clauses across contract drafts and check quoted wording in the original PDF. |
|
|
33
|
+
| Research material | Summarize methods across papers and check a definition against its source page. |
|
|
34
|
+
| Software and documentation | Ask how a configuration setting is used across source files and technical notes. |
|
|
35
|
+
| Course material | Turn lecture slides, readings, and a worksheet into a practice question. See the [midterm example](#student-example-midterm-practice). |
|
|
36
|
+
|
|
37
|
+
## Try it without installing
|
|
38
|
+
|
|
39
|
+
If GitHub opens the attachment as text, use the download arrow (↓) at the top of the file view to save the original `.md` file.
|
|
40
|
+
|
|
41
|
+
### Work example: delivery dates
|
|
42
|
+
|
|
43
|
+
The pack contains a supplier offer (PDF), a delivery schedule (Excel), and a meeting note (text). [Browse the source files](examples/delivery-dates/).
|
|
44
|
+
|
|
45
|
+
1. Open the [delivery dates attachment](examples/delivery-dates-pack/batch_01_of_1.md?plain=1), download it with **↓**, and attach it in your AI chat.
|
|
46
|
+
2. Paste this question and send it with the attachment.
|
|
47
|
+
|
|
48
|
+
> List the pilot and main shipment dates. Cite the Excel sheet and the original PDF page for each date, and flag any page whose text could not be read.
|
|
49
|
+
|
|
50
|
+
3. Check the dates on pages 1 and 3 of the [original supplier offer](https://raw.githubusercontent.com/ahmetemreapo/any2llm/main/examples/delivery-dates/supplier-offer.pdf#page=1).
|
|
51
|
+
|
|
52
|
+
<details>
|
|
53
|
+
<summary>Expected answer</summary>
|
|
54
|
+
|
|
55
|
+
| Shipment | Delivery date | Sources |
|
|
56
|
+
| --- | --- | --- |
|
|
57
|
+
| Pilot | March 12, 2027 | `delivery-schedule.xlsx`, **Schedule** sheet, and `supplier-offer.pdf`, **page 1** |
|
|
58
|
+
| Main | March 26, 2027 | `delivery-schedule.xlsx`, **Schedule** sheet, and `supplier-offer.pdf`, **page 3** |
|
|
59
|
+
|
|
60
|
+
The batch flags page 2 because its text is in an image. Open the original page to read the freight note.
|
|
61
|
+
|
|
62
|
+
</details>
|
|
63
|
+
|
|
64
|
+
### Student example: midterm practice
|
|
65
|
+
|
|
66
|
+
Four research methods practice files (PDF, PowerPoint, Word, and Excel) fit in one attachment. The CLI also generates [the full chat prompt](examples/midterm/en/PROMPT.txt).
|
|
67
|
+
|
|
68
|
+
1. Open the [midterm attachment](examples/midterm/en/batch_01_of_1.md?plain=1), download it with **↓**, and attach it in your AI chat.
|
|
69
|
+
2. Paste this question and send it with the attachment.
|
|
70
|
+
|
|
71
|
+
> Which research design fits the measurement plan? Cite the Excel sheet for what was measured in each class and the original PDF page for the design definition.
|
|
72
|
+
|
|
73
|
+
3. Check the definition on [page 2 of the original PDF](https://raw.githubusercontent.com/ahmetemreapo/any2llm/main/src/any2llm/demo_assets/en/research-designs.pdf#page=2). If your viewer opens on page 1, scroll to page 2.
|
|
74
|
+
|
|
75
|
+
<details>
|
|
76
|
+
<summary>Expected answer</summary>
|
|
77
|
+
|
|
78
|
+
The plan uses a **quasi-experimental pretest–posttest design with a nonequivalent comparison group**. Two existing classes take the same 10-item terms test before and after the activity, with no random assignment. Class A recalls the terms from memory and Class B rereads them, each for eight minutes. See the **Plan** sheet in `measurement-plan.xlsx` and **page 2** of `research-designs.pdf`.
|
|
79
|
+
|
|
80
|
+
</details>
|
|
81
|
+
|
|
82
|
+
If the example helps with work you do, consider giving the repository a star.
|
|
83
|
+
|
|
84
|
+
## How is this different?
|
|
85
|
+
|
|
86
|
+
any2llm keeps the PDF page numbers inside the chat attachments and generates a prompt that asks for source citations and guides multi-batch chats. A dash marks a feature left unspecified here.
|
|
87
|
+
|
|
88
|
+
| Tool | PDF page numbers | Output splitting | OCR | Local processing | Example inputs | Chat instructions |
|
|
89
|
+
| --- | --- | --- | --- | --- | --- | --- |
|
|
90
|
+
| **any2llm** | Page tags in Markdown | Token-budgeted Markdown batches | Optional Tesseract for PDF pages without usable text | Local extraction and OCR | PDF, DOCX, PPTX, XLSX, text, code | Generated citation prompt and continuation messages |
|
|
91
|
+
| MarkItDown | — | — | Vision model via OCR plugin | Local file conversion is available | PDF, Word, PowerPoint, Excel, CSV, HTML | — |
|
|
92
|
+
| Docling | Page numbers in document provenance | JSONL chunks with a configurable token budget | Configurable OCR engines | Local execution is available | PDF, DOCX, PPTX, XLSX, HTML, images | — |
|
|
93
|
+
| Pandoc | — | Section-based chunks in HTML output | — | Local CLI | Markdown, HTML, LaTeX, DOCX, EPUB | — |
|
|
94
|
+
| Repomix | — | Numbered output files by size | — | Local CLI | Repository files such as code and Markdown | Includes a user-written instructions file |
|
|
95
|
+
|
|
96
|
+
Official sources
|
|
97
|
+
|
|
98
|
+
- MarkItDown ([project README](https://github.com/microsoft/markitdown/blob/main/README.md), [OCR plugin](https://github.com/microsoft/markitdown/tree/main/packages/markitdown-ocr))
|
|
99
|
+
- Docling ([formats and chunks](https://docling-project.github.io/docling/usage/supported_formats/), [page provenance](https://docling-project.github.io/docling/reference/docling_document/#docling_core.types.doc.ProvenanceItem), [OCR engines](https://docling-project.github.io/docling/getting_started/installation/#ocr-engines), [local execution](https://docling-project.github.io/docling/))
|
|
100
|
+
- Pandoc ([input formats](https://pandoc.org/MANUAL.html#option--from), [chunked HTML](https://pandoc.org/MANUAL.html#chunked-html))
|
|
101
|
+
- Repomix ([quick start](https://repomix.com/guide/), [output splitting](https://repomix.com/guide/configuration), [custom instructions](https://repomix.com/guide/custom-instructions))
|
|
102
|
+
|
|
103
|
+
## Pack your own folder
|
|
104
|
+
|
|
105
|
+
Replace the example path with your folder. Keep the quotes around paths with spaces.
|
|
106
|
+
|
|
107
|
+
```sh
|
|
108
|
+
any2llm "./documents" --lang en
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
1. Choose your preferences on the first run, then select the files to include.
|
|
112
|
+
2. Attach the numbered Markdown files from the `_llm_pack` output folder. Paste the generated `PROMPT.txt` text into the chat.
|
|
113
|
+
3. For multiple batches, follow the terminal’s upload order and send the continuation word in the same chat when another batch remains. Model behavior can vary. If the model does not move on, resend your last message and name the next batch, attaching its file if you haven’t already. Verify important PDF citations in the original.
|
|
114
|
+
|
|
115
|
+
Use `-r` to include subfolders, `--max-tokens` to set a per-batch token budget, `--task` to supply your question, and `--details` to see every reported skip. Token counts can differ from your chat service’s.
|
|
116
|
+
|
|
117
|
+
The terminal and generated prompts support 11 languages via `--lang` (`en`, `zh`, `hi`, `es`, `fr`, `ar`, `bn`, `pt`, `ru`, `ur`, `tr`). See the [CLI reference](docs/SPEC.md#command-line-options).
|
|
118
|
+
|
|
119
|
+
Run the bundled midterm demo with `any2llm demo --lang en --no-open`. It prints the path to a fresh output folder.
|
|
120
|
+
|
|
121
|
+
## Limits, privacy, and OCR
|
|
122
|
+
|
|
123
|
+
- **Extraction.** Batches keep PDF text and physical page numbers, Word and PowerPoint text and tables, visible Excel sheets with values and formulas, and readable text and code. Charts, images, and layout can be lost. The terminal flags PDF pages with missing or partial text. Check the original wherever an answer depends on an important detail or a visual.
|
|
124
|
+
- **File limits.** Up to 32 MiB per source file, 500 pages per PDF, 128 MiB uncompressed per Office archive, and 120 seconds per file for extraction. Unreadable, encrypted, and unsupported files are reported and skipped. Your chat’s attachment and context limits still apply.
|
|
125
|
+
- **Privacy.** Extraction and OCR run locally. tiktoken may download its vocabulary on first use. Review the output before uploading it to a chat. The CLI skips common credential filenames and warns about some credential patterns in extracted text, which stays in the output. See the [security policy](SECURITY.md).
|
|
126
|
+
- **OCR.** Install Poppler (`pdftoppm`) and Tesseract with the language data you need. Add their installation directories to `PATH` as absolute paths. Use `--ocr` for English or `--ocr-lang` to choose installed languages independently of the chat prompt language. OCR tries PDF pages without usable text and marks recognized pages in the batch. Check important names and numbers against the scan. [Tesseract installation guide](https://tesseract-ocr.github.io/tessdoc/Installation.html)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# any2llm
|
|
2
|
+
|
|
3
|
+
**Ask AI about your documents, then check its PDF citations on the original pages.**
|
|
4
|
+
|
|
5
|
+
any2llm turns a folder of PDF, Word, PowerPoint, Excel, text, and code files into numbered Markdown attachments and a ready-to-paste chat prompt. It keeps physical PDF page numbers and flags pages with missing or partial text so you can check the original.
|
|
6
|
+
|
|
7
|
+
- Set a token budget per batch and use the generated prompt to guide the chat through multiple attachments.
|
|
8
|
+
- Extract text on your computer. Optional OCR for PDF pages without usable text uses Poppler and Tesseract.
|
|
9
|
+
- Choose from 11 languages for terminal output and chat prompts.
|
|
10
|
+
|
|
11
|
+
Requires Python 3.11 or newer. Find examples, usage instructions, and extraction limits in the [GitHub repository](https://github.com/ahmetemreapo/any2llm).
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=84.1.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "any2llm"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "Pack mixed documents into Markdown batches for AI chats with original PDF page numbers"
|
|
9
|
+
readme = {file = "docs/pypi.md", content-type = "text/markdown"}
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{name = "Ahmet Emre Apo"}]
|
|
14
|
+
keywords = ["pdf", "docx", "pptx", "xlsx", "markdown", "llm", "ocr", "document-processing", "cli"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Environment :: Console",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
"Programming Language :: Python :: 3.14",
|
|
24
|
+
"Topic :: Text Processing :: Markup :: Markdown",
|
|
25
|
+
"Topic :: Utilities",
|
|
26
|
+
]
|
|
27
|
+
dependencies = [
|
|
28
|
+
"pypdf", "python-docx>=1.1", "python-pptx", "openpyxl", "defusedxml>=0.7.1",
|
|
29
|
+
"Pillow>=13.0.0",
|
|
30
|
+
"tiktoken", "questionary>=2.1", "rich", "pyperclip",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.urls]
|
|
34
|
+
Repository = "https://github.com/ahmetemreapo/any2llm"
|
|
35
|
+
Documentation = "https://github.com/ahmetemreapo/any2llm/blob/main/docs/SPEC.md"
|
|
36
|
+
Issues = "https://github.com/ahmetemreapo/any2llm/issues"
|
|
37
|
+
Releases = "https://github.com/ahmetemreapo/any2llm/releases"
|
|
38
|
+
|
|
39
|
+
[project.optional-dependencies]
|
|
40
|
+
dev = ["pytest"]
|
|
41
|
+
|
|
42
|
+
[project.scripts]
|
|
43
|
+
any2llm = "any2llm.cli:main"
|
|
44
|
+
|
|
45
|
+
[tool.setuptools.packages.find]
|
|
46
|
+
where = ["src"]
|
|
47
|
+
|
|
48
|
+
[tool.setuptools.package-data]
|
|
49
|
+
any2llm = ["locales/*.json", "demo_assets/*/*.pdf", "demo_assets/*/*.docx", "demo_assets/*/*.pptx", "demo_assets/*/*.xlsx"]
|
|
50
|
+
|
|
51
|
+
[tool.ruff]
|
|
52
|
+
line-length = 120
|
|
53
|
+
target-version = "py311"
|
|
54
|
+
|
|
55
|
+
[tool.ruff.lint]
|
|
56
|
+
select = ["E", "F", "W", "I", "B", "UP", "SIM"]
|
any2llm-0.2.0/setup.cfg
ADDED
|
File without changes
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""Normalize prose and remove repeated PDF page margins."""
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
from collections import Counter
|
|
5
|
+
|
|
6
|
+
_PAGE_NUMBER = re.compile(r"page\s+\d+(?:\s*(?:of|/)\s*\d+)?", re.IGNORECASE)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def clean_text(text: str) -> str:
|
|
10
|
+
"""Trim trailing whitespace and collapse blank lines, preserving indentation."""
|
|
11
|
+
lines = [line.rstrip() for line in text.splitlines()]
|
|
12
|
+
return re.sub(r"\n{3,}", "\n\n", "\n".join(lines)).strip("\n")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def clean_pages(pages: list[str]) -> list[str]:
|
|
16
|
+
"""Clean PDF margins while retaining a slot for every physical page."""
|
|
17
|
+
bodies = []
|
|
18
|
+
for number, page in enumerate(pages, 1):
|
|
19
|
+
lines = clean_text(page).splitlines()
|
|
20
|
+
for edge in (-1, 0):
|
|
21
|
+
if lines:
|
|
22
|
+
margin = lines[edge].strip()
|
|
23
|
+
if margin == str(number) or _PAGE_NUMBER.fullmatch(margin):
|
|
24
|
+
lines.pop(edge)
|
|
25
|
+
lines = "\n".join(lines).strip("\n").splitlines()
|
|
26
|
+
bodies.append(lines)
|
|
27
|
+
|
|
28
|
+
headers = Counter(lines[0] for lines in bodies if len(lines) > 1)
|
|
29
|
+
footers = Counter(lines[-1] for lines in bodies if len(lines) > 1)
|
|
30
|
+
threshold = max(2, sum(bool(lines) for lines in bodies) // 2 + 1)
|
|
31
|
+
cleaned = []
|
|
32
|
+
for lines in bodies:
|
|
33
|
+
if len(lines) > 1 and headers[lines[0]] >= threshold:
|
|
34
|
+
lines = lines[1:]
|
|
35
|
+
if len(lines) > 1 and footers[lines[-1]] >= threshold:
|
|
36
|
+
lines = lines[:-1]
|
|
37
|
+
cleaned.append(clean_text("\n".join(lines)))
|
|
38
|
+
return cleaned
|