Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.
Python ai4sciencedocument-analysisdocxextract-datalayout-analysisocrparserpdfpdf-converterpdf-extractor-llmpdf-extractor-pretrainpdf-extractor-ragpdf-parserpptxpythonxlsx
fix(list): improve list identification accuracy- Adjust the threshold for determining right-side spacing to 0.26 * block_weight - Add TODO comment for special list identification with all centered lines- Modify the condition for recognizing short item lists with left alignment - Update the condition for identifying the end of a list item
myhlolia8f2e7d6c46d
diff --git a/magic_pdf/para/para_split_v3.py b/magic_pdf/para/para_split_v3.pyindex 237c4a5e..b000f0f2 100644--- a/magic_pdf/para/para_split_v3.py+++ b/magic_pdf/para/para_split_v3.py@@ -103,7 +103,7 @@ def __is_list_or_index_block(block):right_close_num += 1else:# 右侧不顶格情况下是否有一段距离,拍脑袋用0.3block宽度做阈值- closed_area = 0.3 * block_weight+ closed_area = 0.26 * block_weight# closed_area = 5 * line_heightif block['bbox_fs'][2] - line['bbox'][2] > closed_area:right_not_close_num += 1@@ -139,10 +139,12 @@ def __is_list_or_index_block(block):line[ListLineTag.IS_LIST_START_LINE] = Truereturn BlockType.Index+ # @TODO 全部line都居中的特殊list识别,每行都需要换行,特征是多行,且大多数行都前后not_close,每line中点x坐标接近+elif left_close_num >= 2 and (right_not_close_num >= 2 or line_end_flag or left_not_close_num >= 2) and not multiple_para_flag:# 处理一种特殊的没有缩进的list,所有行都贴左边,通过右边的空隙判断是否是item尾- if left_close_num / len(block['lines']) > 0.9:+ if left_close_num / len(block['lines']) > 0.8:# 这种是每个item只有一行,且左边都贴边的短item listif flag_end_count == 0 and right_close_num / len(block['lines']) < 0.5:for line in block['lines']:@@ -162,7 +164,8 @@ def __is_list_or_index_block(block):if line_start_flag:line[ListLineTag.IS_LIST_START_LINE] = Trueline_start_flag = False- elif abs(block['bbox_fs'][2] - line['bbox'][2]) > line_height:+ # elif abs(block['bbox_fs'][2] - line['bbox'][2]) > line_height:+ if abs(block['bbox_fs'][2] - line['bbox'][2]) > 0.1 * block_weight:line[ListLineTag.IS_LIST_END_LINE] = Trueline_start_flag = True# 一种有缩进的特殊有序list,start line 左侧不贴边且以数字开头,end line 以 IS_LIST_END_LINE 结尾且数量和start line 一致