Skip to main content

Sohojpath

CI PyPI Python License

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 sohojpath CLI
  • 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

sohojpath-0.1.1.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sohojpath-0.1.1-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

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

Hashes for sohojpath-0.1.1.tar.gz
Algorithm Hash digest
SHA256 77b99263e611fca3004cc94042d445839304c33c3d12c675793bb8dec8407588
MD5 6431f7cbb59580b2d2ea5e418a8e15b7
BLAKE2b-256 56cebcb32da87fa0637c725197a65fc61778b763ad41cb8a7f726759bfb70084

See more details on using hashes here.

Provenance

The following attestation bundles were made for sohojpath-0.1.1.tar.gz:

Publisher: publish.yml on Anindyakafka/sohojpath

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for sohojpath-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fcd06224a77e0fd738a6c24d4e4181dd2734d4cf2f9738fe556172615230f867
MD5 1687851fe5efff80746353d4ada18c69
BLAKE2b-256 ac066d94ecab1d4e9c19e92bddcf9d2fc91055b0e38d96d5d7e7b63b3dc22531

See more details on using hashes here.

Provenance

The following attestation bundles were made for sohojpath-0.1.1-py3-none-any.whl:

Publisher: publish.yml on Anindyakafka/sohojpath

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page