Document-to-knowledge converter. Extracts text from plain text, PDF and DOCX files, splits it into overlapping chunks, and produces an extractive summary using a pure-NumPy TextRank implementation. An optional LLM client can polish the summary when an API key is configured; otherwise a deterministic offline polisher is used automatically.
- Text extraction for
.txt/.md(native),.pdf(pdfplumber) and.docx(python-docx). Optional readers are lazily imported and raise a clear error only when the file type actually needs them. - Word-based chunking with configurable size and overlap.
- Extractive TextRank summarization built on NumPy (cosine-overlap similarity, power-iteration ranking). Deterministic, no network.
- Thin LLM client (
doclify.llm.DocLLMClient) behind an offline fallback: when no API key is present, summaries are polished with a local rule-based routine. - CLI:
python -m doclify process <file> [--summary].
pip install -r requirements.txt
python -m doclify process notes.txt --summary
python -m doclify process notes.txt --summary --json
python -m doclify supported
python -m pytest -qpython -m doclify process FILE [--summary] [--chunk-size N] [--overlap N] [--max-sentences N] [--json]
python -m doclify supported
Example:
python -m doclify process tests/data/sample.txt --summary --chunk-size 256 --overlap 32| Variable | Default | Purpose |
|---|---|---|
DOCLIFY_API_KEY |
OPENAI_API_KEY |
Enables remote summary polish |
DOCLIFY_MODEL |
gpt-4o-mini |
Model used by the LLM client |
DOCLIFY_BASE_URL |
https://api.openai.com/v1 |
OpenAI-compatible endpoint |
When no key is available the offline rule-based polisher is used, so the tool always works without credentials.
doclify/
README.md
requirements.txt
.gitignore
.env.example
doclify/
__init__.py
extractor.py # text extraction (guarded optional imports)
chunker.py # word-based chunking with overlap
summarizer.py # TextRank (pure NumPy)
llm.py # optional LLM client + offline fallback
pipeline.py # end-to-end process_document()
__main__.py # CLI entry
tests/
data/sample.txt
test_smoke.py
MIT