"""文档预处理结果"""
from dataclasses import dataclass, field
from typing import Optional, Dict
import numpy as np


@dataclass
class DocPreprocessResult:
    """文档预处理结果"""
    input_path: Optional[str] = None
    original_shape: tuple = field(default_factory=tuple)
    processed_shape: tuple = field(default_factory=tuple)
    processed_image: Optional[np.ndarray] = None
    
    # 旋转相关
    rotation_angle: str = "0"
    rotation_confidence: float = 1.0
    rotated: bool = False
    vertical_text_count: int = 0
    
    # 调试信息
    debug_info: Optional[Dict] = None
    
    def __str__(self):
        lines = [
            f"DocPreprocessResult:",
            f"  Original shape: {self.original_shape}",
            f"  Rotation: {self.rotation_angle}° (confidence: {self.rotation_confidence:.3f})",
            f"  Vertical texts: {self.vertical_text_count}",
            f"  Rotated: {self.rotated}"
        ]
        
        if self.debug_info:
            lines.append("  Debug info:")
            for key, value in self.debug_info.items():
                lines.append(f"    {key}: {value}")
        
        return "\n".join(lines)