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
7248676d
Unverified
Commit
7248676d
authored
Dec 19, 2024
by
Xiaomeng Zhao
Committed by
GitHub
Dec 19, 2024
Browse files
Merge pull request #1325 from pangguosheng1106/dev
fix: skip the char corresponding to invalid bounding boxes
parents
b71993a9
1e6de549
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
1 deletion
+5
-1
magic_pdf/pdf_parse_union_core_v2.py
magic_pdf/pdf_parse_union_core_v2.py
+4
-0
magic_pdf/pre_proc/remove_bbox_overlap.py
magic_pdf/pre_proc/remove_bbox_overlap.py
+1
-1
No files found.
magic_pdf/pdf_parse_union_core_v2.py
View file @
7248676d
...
@@ -108,6 +108,10 @@ def fill_char_in_spans(spans, all_chars):
...
@@ -108,6 +108,10 @@ def fill_char_in_spans(spans, all_chars):
spans
=
sorted
(
spans
,
key
=
lambda
x
:
x
[
'bbox'
][
1
])
spans
=
sorted
(
spans
,
key
=
lambda
x
:
x
[
'bbox'
][
1
])
for
char
in
all_chars
:
for
char
in
all_chars
:
# 跳过非法bbox的char
x1
,
y1
,
x2
,
y2
=
char
[
'bbox'
]
if
abs
(
x1
-
x2
)
<=
0.01
or
abs
(
y1
-
y2
)
<=
0.01
:
continue
for
span
in
spans
:
for
span
in
spans
:
if
calculate_char_in_span
(
char
[
'bbox'
],
span
[
'bbox'
],
char
[
'c'
]):
if
calculate_char_in_span
(
char
[
'bbox'
],
span
[
'bbox'
],
char
[
'c'
]):
span
[
'chars'
].
append
(
char
)
span
[
'chars'
].
append
(
char
)
...
...
magic_pdf/pre_proc/remove_bbox_overlap.py
View file @
7248676d
...
@@ -70,7 +70,7 @@ def _remove_overlap_between_bboxes(arr):
...
@@ -70,7 +70,7 @@ def _remove_overlap_between_bboxes(arr):
res
[
i
]
=
None
res
[
i
]
=
None
else
:
else
:
keeps
[
idx
]
=
False
keeps
[
idx
]
=
False
drop_reasons
.
append
(
drop_reason
s
)
drop_reasons
.
append
(
drop_reason
)
if
keeps
[
idx
]:
if
keeps
[
idx
]:
res
[
idx
]
=
v
res
[
idx
]
=
v
return
res
,
drop_reasons
return
res
,
drop_reasons
...
...
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