Skip to content

feat: initialize pakdocling core architecture, schemas, preprocessor,… - #14

Merged
milliyin merged 6 commits into
mainfrom
chore/setup-pakdocling
Aug 11, 2026
Merged

feat: initialize pakdocling core architecture, schemas, preprocessor,…#14
milliyin merged 6 commits into
mainfrom
chore/setup-pakdocling

Conversation

@milliyin

@milliyin milliyin commented Aug 11, 2026

Copy link
Copy Markdown
Member

Summary

This PR initializes the core architecture for pakdocling (Pakistani Document Intelligence Library) at version 0.0.1, delivering a Docling-aligned public API for structured data extraction from Pakistani identity and educational documents into validated Pydantic JSON objects.

Closes #13
Closes #6


🚀 Key Changes

1. Docling-Aligned Public API (pakdocling)

  • DocumentConverter: Primary converter class matching Docling's DocumentConverter interface (converter.convert(source, doc_type="cnic")).
  • convert(): Top-level functional helper for 1-line conversions (convert("sample.png")).
  • ConversionResult: Result object with .document (Pydantic model access), .export_to_json(indent=2), and .export_to_dict() methods.
  • Backward Compatibility: DocumentPipeline, extract_document(), and ExtractionResult aliases maintained.

2. OpenCV Image Preprocessing & Modular OCR (pakdocling.preprocessing & pakdocling.ocr)

  • OpenCV Pipeline: Grayscale conversion, edge-preserving denoising (cv2.fastNlMeansDenoising(h=10)), CLAHE contrast enhancement (clipLimit=2.0), document deskewing, and adaptive thresholding.
  • Bounding Box Rectangles: Added ImagePreprocessor.annotate_boxes() to draw green bounding boxes around detected text regions on original images.
  • EasyOCR Integration: Production EasyOCREngine with Urdu & English default languages (['ur', 'en']), lazy loading, and min_confidence=0.2 noise filtering.
  • Mock Engine: Fast MockOCREngine for ultra-fast offline unit testing (<10ms) without model downloads.

3. Document Schemas & Models (pakdocling.models)

  • CNICData: 13-digit CNIC number, full name, father/husband name, gender (with NADRA odd/even validation), DOB, issue & expiry dates, format variant (old_green vs new_blue Smart Card).
  • MatricCertificateData: Roll number, registration number, student & father name, BISE board, passing year, total & obtained marks, grade, group.
  • IntermediateCertificateData: HSSC roll number, BISE board, student & father name, total & obtained marks, grade, group (Pre-Engineering, Pre-Medical, ICS, Commerce, Humanities).
  • UniversityDegreeData: Degree title, major, university name, student & father name, registration number, graduation year, CGPA.

4. Extractors & CLI (pakdocling.extractors & pakdocling.cli)

  • Layout & pattern extractors: CNICExtractor, MatricExtractor, IntermediateExtractor, DegreeExtractor.
  • Typer CLI with pakdocling info, pakdocling convert, and pakdocling extract commands.

🧪 Verification Results

  • Unit Tests: pytest (20/20 passed in 0.28s).
  • Linter & Formatter: ruff format --check . and ruff check . passed (0 issues).
  • Type Checker: mypy pakdocling (0 type errors across 15 source files).
  • CI Matrix: GitHub Actions checks passing on Python 3.10, 3.11, and 3.12.

@milliyin milliyin linked an issue Aug 11, 2026 that may be closed by this pull request
@milliyin
milliyin merged commit 5333306 into main Aug 11, 2026
5 checks passed
@milliyin
milliyin deleted the chore/setup-pakdocling branch August 13, 2026 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pakistani Document Intelligence Library - Core Architecture & Extractors (v1) Define Public API

1 participant