|
|
@@ -62,31 +62,31 @@ class TableLineGenerator:
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
- def parse_ocr_data(ocr_result: Dict, tool: str = "auto") -> Tuple[List[int], Dict]:
|
|
|
+ def parse_ocr_data(ocr_result: Dict, json_format: str = "auto") -> Tuple[List[int], Dict]:
|
|
|
"""
|
|
|
统一的 OCR 数据解析接口(第一步:仅读取数据)
|
|
|
|
|
|
Args:
|
|
|
ocr_result: OCR 识别结果(完整 JSON)
|
|
|
- tool: 工具类型 ("ppstructv3" / "mineru")
|
|
|
+ json_format: 数据格式类型 ("ppstructure" / "mineru")
|
|
|
|
|
|
Returns:
|
|
|
(table_bbox, ocr_data): 表格边界框和文本框列表
|
|
|
"""
|
|
|
- if tool.lower() == "auto":
|
|
|
- tool_type = TableLineGenerator.detect_ocr_tool_type(ocr_result)
|
|
|
+ if json_format.lower() == "auto":
|
|
|
+ json_format_type = TableLineGenerator.detect_json_format(ocr_result)
|
|
|
else:
|
|
|
- tool_type = tool.lower() if tool else None
|
|
|
+ json_format_type = json_format.lower() if json_format else None
|
|
|
|
|
|
- if tool_type == "ppstructure":
|
|
|
+ if json_format_type == "ppstructure":
|
|
|
return TableLineGenerator._parse_ppstructure_data(ocr_result)
|
|
|
- elif tool_type == "mineru":
|
|
|
+ elif json_format_type == "mineru":
|
|
|
return TableLineGenerator._parse_mineru_data(ocr_result)
|
|
|
else:
|
|
|
- raise ValueError(f"不支持的工具类型: {tool}")
|
|
|
+ raise ValueError(f"不支持的数据格式类型: {json_format}")
|
|
|
|
|
|
@staticmethod
|
|
|
- def detect_ocr_tool_type(ocr_result: Dict) -> str:
|
|
|
+ def detect_json_format(ocr_result: Dict) -> str:
|
|
|
"""
|
|
|
检测 OCR 工具类型
|
|
|
"""
|