File size: 1,395 Bytes
b25b944
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""Document processing orchestration.



Module 1 - Osprey Backend: Document processing application.

"""

from typing import Dict, Any, Optional, Tuple

# This module will contain the main document processing logic
# Currently a stub - will be populated by extracting logic from app.py

def detect_pdf_text_layer(pdf_bytes: bytes, max_pages_check: int = 3) -> Tuple[bool, list]:
    """

    Detect if PDF has a text layer by checking first few pages.

    

    Args:

        pdf_bytes: PDF file bytes

        max_pages_check: Maximum number of pages to check

        

    Returns:

        Tuple of (has_text_layer, page_texts)

    """
    # Stub - will be extracted from app.py
    return False, []


def should_disable_ocr_for_page1(osd_fail_count: int) -> bool:
    """Determine if OCR should be disabled based on OSD failure count.

    

    Args:

        osd_fail_count: Number of OSD failures

        

    Returns:

        True if OCR should be disabled

    """
    # Stub - will be extracted from app.py
    return False


def normalize_ocr_engine_name(engine) -> str:
    """Normalize OCR engine name for consistent logging.

    

    Args:

        engine: OCR engine object or name

        

    Returns:

        Normalized engine name string

    """
    # Stub - will be extracted from app.py
    return str(engine) if engine else "unknown"