|
@@ -360,6 +360,7 @@ class TextFiller:
|
|
|
texts: List[str],
|
|
texts: List[str],
|
|
|
scores: Optional[List[float]] = None,
|
|
scores: Optional[List[float]] = None,
|
|
|
need_reocr_indices: Optional[List[int]] = None,
|
|
need_reocr_indices: Optional[List[int]] = None,
|
|
|
|
|
+ pdf_type: str = 'ocr', # 'ocr' 或 'txt'
|
|
|
force_all: bool = False,
|
|
force_all: bool = False,
|
|
|
output_dir: Optional[str] = None,
|
|
output_dir: Optional[str] = None,
|
|
|
) -> List[str]:
|
|
) -> List[str]:
|
|
@@ -378,6 +379,7 @@ class TextFiller:
|
|
|
texts: 当前文本列表
|
|
texts: 当前文本列表
|
|
|
scores: 当前置信度列表
|
|
scores: 当前置信度列表
|
|
|
need_reocr_indices: 需要二次 OCR 的单元格索引列表(OCR 误合并检测结果)
|
|
need_reocr_indices: 需要二次 OCR 的单元格索引列表(OCR 误合并检测结果)
|
|
|
|
|
+ pdf_type: str, # 'ocr' 或 'txt'
|
|
|
force_all: 是否强制对所有单元格进行 OCR (Default: False)
|
|
force_all: 是否强制对所有单元格进行 OCR (Default: False)
|
|
|
output_dir: 输出目录,如果提供则保存单元格OCR图片到 {output_dir}/tablecell_ocr/ 目录
|
|
output_dir: 输出目录,如果提供则保存单元格OCR图片到 {output_dir}/tablecell_ocr/ 目录
|
|
|
"""
|
|
"""
|
|
@@ -424,8 +426,12 @@ class TextFiller:
|
|
|
else:
|
|
else:
|
|
|
# 1. 文本为空且置信度不是极高
|
|
# 1. 文本为空且置信度不是极高
|
|
|
if (not t or not t.strip()) and scores[i] < 0.95:
|
|
if (not t or not t.strip()) and scores[i] < 0.95:
|
|
|
- need_reocr = True
|
|
|
|
|
- reocr_reason = "空文本"
|
|
|
|
|
|
|
+ if pdf_type == 'txt':
|
|
|
|
|
+ # PDF文本模式下,空文本不触发二次OCR
|
|
|
|
|
+ need_reocr = False
|
|
|
|
|
+ else:
|
|
|
|
|
+ need_reocr = True
|
|
|
|
|
+ reocr_reason = "空文本"
|
|
|
# 2. 置信度过低
|
|
# 2. 置信度过低
|
|
|
elif scores[i] < trigger_score_thresh:
|
|
elif scores[i] < trigger_score_thresh:
|
|
|
need_reocr = True
|
|
need_reocr = True
|