Sohojpath
Sohojpath is a Python library and command-line tool for geometry-preserving Bengali PDF OCR. It extracts normalized Unicode text while retaining each word's bounding box, Tesseract line identifiers, and confidence score for table extraction, document analysis, and human review.
Sohojpath is currently alpha software. OCR output is not ground truth; validate critical fields and retain a manual-review path.
Features
- Bengali or bilingual OCR through Tesseract (
ben,ben+eng, or another installed set) - Normalized UTF-8 plain-text output
- Page-level JSON Lines with word coordinates and confidence
- One-based page selection such as
1,3-5 - Python API and
sohojpathCLI - Explicit language-data diagnostics
- Type information through
py.typed
Requirements and installation
Sohojpath requires Python 3.10 or newer and Tesseract OCR with Bengali language data.
# Windows
winget install UB-Mannheim.TesseractOCR
# Ubuntu/Debian
sudo apt install tesseract-ocr tesseract-ocr-ben
# macOS
brew install tesseract tesseract-lang
Install Sohojpath:
python -m pip install sohojpath
For development from a clone:
python -m pip install -e ".[dev]"
Command line
# Check Tesseract and language availability
sohojpath doctor
# Extract normalized text
sohojpath text document.pdf --pages 1-3 --output document.txt
# Extract page-level JSON Lines with word geometry
sohojpath ocr document.pdf --pages 1-3 --output document.jsonl
Useful options:
--language ben+eng Tesseract languages
--dpi 300 Rendering resolution
--psm 6 Tesseract page-segmentation mode
--minimum-confidence 40 Exclude lower-confidence words
--tesseract PATH Explicit Tesseract executable
--tessdata PATH Explicit language-data directory
--timeout SECONDS Maximum time for each Tesseract invocation
Run sohojpath COMMAND --help for the complete command reference.
Python API
from sohojpath import BanglaPdfParser, ParserConfig
parser = BanglaPdfParser(ParserConfig(language="ben+eng", dpi=300))
for page in parser.parse("document.pdf", pages=[1, 2]):
print(page.page, page.text)
for word in page.words:
print(word.text, word.confidence, word.left, word.top)
If language files are outside Tesseract's default location, pass
ParserConfig(tessdata=Path("path/to/tessdata")).
Structured output
The ocr command emits JSON Lines so large PDFs can be processed incrementally. Each page
contains its source, one-based page number, DPI, pixel dimensions, normalized text, and
words with confidence, bounding box, block, paragraph, and line identifiers.
Coordinates are integer pixels in the page image rendered at the requested DPI. Pages are emitted in the requested order; words are emitted in Tesseract's TSV order. The synthesized page text groups words by Tesseract block, paragraph, and line identifiers and orders them top-to-bottom, then left-to-right.
The JSONL structure is considered provisional during the 0.x series. Incompatible schema changes will be called out in the changelog.
Scope and accuracy
Version 0.1 provides a reusable OCR and geometry layer. Document-specific schemas—such as electoral rolls, forms, registers, or fixed-column tables—should be implemented as opt-in profiles on top of the word geometry API.
Applications handling names, identity numbers, legal records, or other sensitive fields should preserve source documents, confidence values, validation results, and review decisions.
Development
python -m pip install -e ".[dev]"
python -m ruff format --check .
python -m ruff check .
python -m mypy
python -m coverage run -m unittest discover -s tests -v
python -m coverage report
python -m build
python -m twine check dist/*
The Python API raises ValueError for invalid configuration or page selection,
FileNotFoundError for a missing input or Tesseract executable, and RuntimeError for PDF,
language-data, malformed OCR output, timeout, and Tesseract execution failures. The CLI
reports these failures on standard error and exits with status 2.
See CONTRIBUTING.md, SUPPORT.md, and SECURITY.md.
License
Licensed under the Apache License 2.0.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sohojpath-0.1.1.tar.gz.
File metadata
- Download URL: sohojpath-0.1.1.tar.gz
- Upload date:
- Size: 18.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77b99263e611fca3004cc94042d445839304c33c3d12c675793bb8dec8407588
|
|
| MD5 |
6431f7cbb59580b2d2ea5e418a8e15b7
|
|
| BLAKE2b-256 |
56cebcb32da87fa0637c725197a65fc61778b763ad41cb8a7f726759bfb70084
|
Provenance
The following attestation bundles were made for sohojpath-0.1.1.tar.gz:
Publisher:
publish.yml on Anindyakafka/sohojpath
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sohojpath-0.1.1.tar.gz -
Subject digest:
77b99263e611fca3004cc94042d445839304c33c3d12c675793bb8dec8407588 - Sigstore transparency entry: 2570461715
- Sigstore integration time:
-
Permalink:
Anindyakafka/sohojpath@c715035ae7bc39cd75f8c50fe81e51c209e8da05 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Anindyakafka
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c715035ae7bc39cd75f8c50fe81e51c209e8da05 -
Trigger Event:
release
-
Statement type:
File details
Details for the file sohojpath-0.1.1-py3-none-any.whl.
File metadata
- Download URL: sohojpath-0.1.1-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcd06224a77e0fd738a6c24d4e4181dd2734d4cf2f9738fe556172615230f867
|
|
| MD5 |
1687851fe5efff80746353d4ada18c69
|
|
| BLAKE2b-256 |
ac066d94ecab1d4e9c19e92bddcf9d2fc91055b0e38d96d5d7e7b63b3dc22531
|
Provenance
The following attestation bundles were made for sohojpath-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on Anindyakafka/sohojpath
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sohojpath-0.1.1-py3-none-any.whl -
Subject digest:
fcd06224a77e0fd738a6c24d4e4181dd2734d4cf2f9738fe556172615230f867 - Sigstore transparency entry: 2570461729
- Sigstore integration time:
-
Permalink:
Anindyakafka/sohojpath@c715035ae7bc39cd75f8c50fe81e51c209e8da05 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Anindyakafka
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c715035ae7bc39cd75f8c50fe81e51c209e8da05 -
Trigger Event:
release
-
Statement type: