处理样式(主入口) Args: text_blocks: 文字块列表 ocr_styles: OCR 返回的全局 styles 列表(若有) unify: 是否执行聚类统一
(
self,
text_blocks: List[Dict[str, Any]],
ocr_styles: List[Dict] = None,
unify: bool = True,
)
| 29 | pass |
| 30 | |
| 31 | def process( |
| 32 | self, |
| 33 | text_blocks: List[Dict[str, Any]], |
| 34 | ocr_styles: List[Dict] = None, |
| 35 | unify: bool = True, |
| 36 | ) -> List[Dict[str, Any]]: |
| 37 | """ |
| 38 | 处理样式(主入口) |
| 39 | |
| 40 | Args: |
| 41 | text_blocks: 文字块列表 |
| 42 | ocr_styles: OCR 返回的全局 styles 列表(若有) |
| 43 | unify: 是否执行聚类统一 |
| 44 | """ |
| 45 | ocr_styles = ocr_styles or [] |
| 46 | |
| 47 | result = self.extract_styles(text_blocks, ocr_styles) |
| 48 | |
| 49 | # 步骤 2: 聚类统一 |
| 50 | if unify and len(result) > 1: |
| 51 | result = self.unify_by_clustering(result) |
| 52 | |
| 53 | return result |
| 54 | |
| 55 | def extract_styles( |
| 56 | self, |
no test coverage detected