Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pdf-miner
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Qin Kaijie
pdf-miner
Commits
f1252e71
Commit
f1252e71
authored
May 08, 2024
by
赵小蒙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix lost image bug
parent
875b5db1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
ocr_dict_merge.py
magic_pdf/pre_proc/ocr_dict_merge.py
+6
-5
No files found.
magic_pdf/pre_proc/ocr_dict_merge.py
View file @
f1252e71
from
loguru
import
logger
from
magic_pdf.libs.boxbase
import
__is_overlaps_y_exceeds_threshold
,
get_minbox_if_overlap_by_ratio
,
\
calculate_overlap_area_in_bbox1_area_ratio
calculate_overlap_area_in_bbox1_area_ratio
,
_is_in_or_part_overlap_with_area_ratio
from
magic_pdf.libs.drop_tag
import
DropTag
from
magic_pdf.libs.ocr_content_type
import
ContentType
,
BlockType
from
magic_pdf.pre_proc.ocr_span_list_modify
import
modify_y_axis
,
modify_inline_equation
...
...
@@ -247,10 +247,11 @@ def fix_image_block(block, img_blocks):
block
[
'blocks'
]
=
[]
# 遍历img_blocks,找到与当前block匹配的img_block
for
img_block
in
img_blocks
:
if
img_block
[
'bbox'
]
==
block
[
'bbox'
]:
if
_is_in_or_part_overlap_with_area_ratio
(
block
[
'bbox'
],
img_block
[
'bbox'
],
0.95
):
# 创建img_body_block
for
span
in
block
[
'spans'
]:
if
span
[
'type'
]
==
ContentType
.
Image
and
span
[
'bbox'
]
==
img_block
[
'img_body_
bbox'
]:
if
span
[
'type'
]
==
ContentType
.
Image
and
img_block
[
'img_body_bbox'
]
==
span
[
'
bbox'
]:
# 创建img_body_block
img_body_block
=
make_body_block
(
span
,
img_block
[
'img_body_bbox'
],
BlockType
.
ImageBody
)
block
[
'blocks'
]
.
append
(
img_body_block
)
...
...
@@ -275,11 +276,11 @@ def fix_table_block(block, table_blocks):
block
[
'blocks'
]
=
[]
# 遍历table_blocks,找到与当前block匹配的table_block
for
table_block
in
table_blocks
:
if
table_block
[
'bbox'
]
==
block
[
'bbox'
]
:
if
_is_in_or_part_overlap_with_area_ratio
(
block
[
'bbox'
],
table_block
[
'bbox'
],
0.95
)
:
# 创建table_body_block
for
span
in
block
[
'spans'
]:
if
span
[
'type'
]
==
ContentType
.
Table
and
span
[
'bbox'
]
==
table_block
[
'table_body_
bbox'
]:
if
span
[
'type'
]
==
ContentType
.
Table
and
table_block
[
'table_body_bbox'
]
==
span
[
'
bbox'
]:
# 创建table_body_block
table_body_block
=
make_body_block
(
span
,
table_block
[
'table_body_bbox'
],
BlockType
.
TableBody
)
block
[
'blocks'
]
.
append
(
table_body_block
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment