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
1c491e7d
Commit
1c491e7d
authored
Jul 04, 2025
by
myhloli
Browse files
refactor: rename vertical text thresholds for clarity in span_block_fix.py
parent
e56eec0d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
mineru/utils/span_block_fix.py
mineru/utils/span_block_fix.py
+4
-3
No files found.
mineru/utils/span_block_fix.py
View file @
1c491e7d
...
...
@@ -73,10 +73,11 @@ def fix_text_block(block):
span
[
'type'
]
=
ContentType
.
INLINE_EQUATION
# 假设block中的span超过80%的数量高度是宽度的两倍以上,则认为是纵向文本块
VERTICAL_TEXT_RATIO_THRESHOLD
=
2
# Threshold for determining vertical text blocks
VERTICAL_SPAN_HEIGHT_WIDTH_THRESHOLD
=
2
# Threshold for determining vertical text blocks
VERTICAL_SPAN_IN_BLOCK_THRESHOLD
=
0.8
# Threshold for determining vertical text blocks
vertical_span_count
=
sum
(
1
for
span
in
block
[
'spans'
]
if
(
span
[
'bbox'
][
3
]
-
span
[
'bbox'
][
1
])
/
(
span
[
'bbox'
][
2
]
-
span
[
'bbox'
][
0
])
>
VERTICAL_
TEXT_RATIO
_THRESHOLD
if
(
span
[
'bbox'
][
3
]
-
span
[
'bbox'
][
1
])
/
(
span
[
'bbox'
][
2
]
-
span
[
'bbox'
][
0
])
>
VERTICAL_
SPAN_HEIGHT_WIDTH
_THRESHOLD
)
total_span_count
=
len
(
block
[
'spans'
])
if
total_span_count
==
0
:
...
...
@@ -84,7 +85,7 @@ def fix_text_block(block):
else
:
vertical_ratio
=
vertical_span_count
/
total_span_count
if
vertical_ratio
>
VERTICAL_
TEXT
_BLOCK_THRESHOLD
:
if
vertical_ratio
>
VERTICAL_
SPAN_IN
_BLOCK_THRESHOLD
:
# 如果是纵向文本块,则按纵向lines处理
block_lines
=
merge_spans_to_vertical_line
(
block
[
'spans'
])
sort_block_lines
=
vertical_line_sort_spans_from_top_to_bottom
(
block_lines
)
...
...
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