feat: initialize pakdocling core architecture, schemas, preprocessor,… - #14
Merged
Conversation
… extractors, CLI, and test suite
…-party imports and auto-detect runner python version
…vert, ConversionResult)
Closed
… and bounding box annotation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR initializes the core architecture for
pakdocling(Pakistani Document Intelligence Library) at version0.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'sDocumentConverterinterface (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.DocumentPipeline,extract_document(), andExtractionResultaliases maintained.2. OpenCV Image Preprocessing & Modular OCR (
pakdocling.preprocessing&pakdocling.ocr)cv2.fastNlMeansDenoising(h=10)), CLAHE contrast enhancement (clipLimit=2.0), document deskewing, and adaptive thresholding.ImagePreprocessor.annotate_boxes()to draw green bounding boxes around detected text regions on original images.EasyOCREnginewith Urdu & English default languages (['ur', 'en']), lazy loading, andmin_confidence=0.2noise filtering.MockOCREnginefor 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_greenvsnew_blueSmart 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)CNICExtractor,MatricExtractor,IntermediateExtractor,DegreeExtractor.pakdocling info,pakdocling convert, andpakdocling extractcommands.🧪 Verification Results
pytest(20/20 passed in 0.28s).ruff format --check .andruff check .passed (0 issues).mypy pakdocling(0 type errors across 15 source files).