Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wangsen
MinerU
Commits
a8ea5d4a
Unverified
Commit
a8ea5d4a
authored
Nov 21, 2024
by
Xiaomeng Zhao
Committed by
GitHub
Nov 21, 2024
Browse files
Merge pull request #1046 from myhloli/dev
refactor(ocr_dict_merge): add threshold parameter for line merging
parents
9c8d995e
b9f78c9b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
magic_pdf/pre_proc/ocr_dict_merge.py
magic_pdf/pre_proc/ocr_dict_merge.py
+2
-2
No files found.
magic_pdf/pre_proc/ocr_dict_merge.py
View file @
a8ea5d4a
...
...
@@ -24,7 +24,7 @@ def line_sort_spans_by_left_to_right(lines):
return
line_objects
def
merge_spans_to_line
(
spans
):
def
merge_spans_to_line
(
spans
,
threshold
=
0.6
):
if
len
(
spans
)
==
0
:
return
[]
else
:
...
...
@@ -49,7 +49,7 @@ def merge_spans_to_line(spans):
continue
# 如果当前的span与当前行的最后一个span在y轴上重叠,则添加到当前行
if
__is_overlaps_y_exceeds_threshold
(
span
[
'bbox'
],
current_line
[
-
1
][
'bbox'
],
0.5
):
if
__is_overlaps_y_exceeds_threshold
(
span
[
'bbox'
],
current_line
[
-
1
][
'bbox'
],
threshold
):
current_line
.
append
(
span
)
else
:
# 否则,开始新行
...
...
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