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
6c8361fa
Unverified
Commit
6c8361fa
authored
Apr 25, 2024
by
myhloli
Committed by
GitHub
Apr 25, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #69 from myhloli/master
change remove spans logic
parents
7a745664
fcf94b2d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
ocr_span_list_modify.py
magic_pdf/pre_proc/ocr_span_list_modify.py
+7
-4
No files found.
magic_pdf/pre_proc/ocr_span_list_modify.py
View file @
6c8361fa
...
...
@@ -9,16 +9,19 @@ from magic_pdf.libs.ocr_content_type import ContentType, BlockType
def
remove_overlaps_min_spans
(
spans
):
dropped_spans
=
[]
# 删除重叠spans中较小的那些
for
span1
in
spans
.
copy
()
:
for
span2
in
spans
.
copy
()
:
for
span1
in
spans
:
for
span2
in
spans
:
if
span1
!=
span2
:
overlap_box
=
get_minbox_if_overlap_by_ratio
(
span1
[
'bbox'
],
span2
[
'bbox'
],
0.65
)
if
overlap_box
is
not
None
:
bbox_to_remove
=
next
((
span
for
span
in
spans
if
span
[
'bbox'
]
==
overlap_box
),
None
)
if
bbox_to_remove
is
not
None
:
spans
.
remove
(
bbox_to_remove
)
bbox_to_remove
[
'tag'
]
=
DropTag
.
SPAN_OVERLAP
dropped_spans
.
append
(
bbox_to_remove
)
if
len
(
dropped_spans
>
0
):
for
dropped_span
in
dropped_spans
:
spans
.
remove
(
dropped_span
)
dropped_span
[
'tag'
]
=
DropTag
.
SPAN_OVERLAP
return
spans
,
dropped_spans
...
...
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