|
@@ -16,23 +16,23 @@ except ImportError:
|
|
|
|
|
|
|
|
def get_structure_from_ocr(
|
|
def get_structure_from_ocr(
|
|
|
raw_data: Dict,
|
|
raw_data: Dict,
|
|
|
- tool: str = "ppstructv3"
|
|
|
|
|
|
|
+ json_format: str = "ppstructure"
|
|
|
) -> Tuple[List[int], Dict]:
|
|
) -> Tuple[List[int], Dict]:
|
|
|
"""
|
|
"""
|
|
|
从 OCR 数据生成表格结构(统一处理流程)
|
|
从 OCR 数据生成表格结构(统一处理流程)
|
|
|
|
|
|
|
|
Args:
|
|
Args:
|
|
|
raw_data: 原始 OCR 结果
|
|
raw_data: 原始 OCR 结果
|
|
|
- tool: 工具类型 ("ppstructv3" / "mineru")
|
|
|
|
|
|
|
+ json_format: 数据格式类型 ("ppstructure" / "mineru")
|
|
|
|
|
|
|
|
Returns:
|
|
Returns:
|
|
|
(table_bbox, structure): 表格边界框和结构信息
|
|
(table_bbox, structure): 表格边界框和结构信息
|
|
|
"""
|
|
"""
|
|
|
# 🎯 第一步:解析数据(统一接口)
|
|
# 🎯 第一步:解析数据(统一接口)
|
|
|
- table_bbox, ocr_data = TableLineGenerator.parse_ocr_data(raw_data, tool)
|
|
|
|
|
|
|
+ table_bbox, ocr_data = TableLineGenerator.parse_ocr_data(raw_data, json_format)
|
|
|
|
|
|
|
|
# 🎯 第二步:分析结构(根据工具选择算法)
|
|
# 🎯 第二步:分析结构(根据工具选择算法)
|
|
|
- if tool.lower() == "mineru":
|
|
|
|
|
|
|
+ if json_format.lower() == "mineru":
|
|
|
# ✅ 使用静态方法,无需图片
|
|
# ✅ 使用静态方法,无需图片
|
|
|
structure = TableLineGenerator.analyze_structure_only(
|
|
structure = TableLineGenerator.analyze_structure_only(
|
|
|
ocr_data,
|
|
ocr_data,
|