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
6f571bb7
Unverified
Commit
6f571bb7
authored
Mar 04, 2025
by
Xiaomeng Zhao
Committed by
GitHub
Mar 04, 2025
Browse files
Merge pull request #1839 from opendatalab/release-1.2.2
Release 1.2.2
parents
5db81bf0
380cb4d9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
14 deletions
+17
-14
magic_pdf/post_proc/para_split_v3.py
magic_pdf/post_proc/para_split_v3.py
+16
-13
requirements.txt
requirements.txt
+1
-1
No files found.
magic_pdf/post_proc/para_split_v3.py
View file @
6f571bb7
...
@@ -108,30 +108,33 @@ def __is_list_or_index_block(block):
...
@@ -108,30 +108,33 @@ def __is_list_or_index_block(block):
):
):
multiple_para_flag
=
True
multiple_para_flag
=
True
for
line
in
block
[
'lines'
]:
block_text
=
''
line_mid_x
=
(
line
[
'bbox'
][
0
]
+
line
[
'bbox'
][
2
])
/
2
block_mid_x
=
(
block
[
'bbox_fs'
][
0
]
+
block
[
'bbox_fs'
][
2
])
/
2
if
(
line
[
'bbox'
][
0
]
-
block
[
'bbox_fs'
][
0
]
>
0.7
*
line_height
and
block
[
'bbox_fs'
][
2
]
-
line
[
'bbox'
][
2
]
>
0.7
*
line_height
):
external_sides_not_close_num
+=
1
if
abs
(
line_mid_x
-
block_mid_x
)
<
line_height
/
2
:
center_close_num
+=
1
for
line
in
block
[
'lines'
]:
line_text
=
''
line_text
=
''
for
span
in
line
[
'spans'
]:
for
span
in
line
[
'spans'
]:
span_type
=
span
[
'type'
]
span_type
=
span
[
'type'
]
if
span_type
==
ContentType
.
Text
:
if
span_type
==
ContentType
.
Text
:
line_text
+=
span
[
'content'
].
strip
()
line_text
+=
span
[
'content'
].
strip
()
# 添加所有文本,包括空行,保持与block['lines']长度一致
# 添加所有文本,包括空行,保持与block['lines']长度一致
lines_text_list
.
append
(
line_text
)
lines_text_list
.
append
(
line_text
)
block_text
=
''
.
join
(
lines_text_list
)
block_text
=
''
.
join
(
lines_text_list
)
block_lang
=
detect_lang
(
block_text
)
block_lang
=
detect_lang
(
block_text
)
# logger.info(f"block_lang: {block_lang}")
# logger.info(f"block_lang: {block_lang}")
for
line
in
block
[
'lines'
]:
line_mid_x
=
(
line
[
'bbox'
][
0
]
+
line
[
'bbox'
][
2
])
/
2
block_mid_x
=
(
block
[
'bbox_fs'
][
0
]
+
block
[
'bbox_fs'
][
2
])
/
2
if
(
line
[
'bbox'
][
0
]
-
block
[
'bbox_fs'
][
0
]
>
0.7
*
line_height
and
block
[
'bbox_fs'
][
2
]
-
line
[
'bbox'
][
2
]
>
0.7
*
line_height
):
external_sides_not_close_num
+=
1
if
abs
(
line_mid_x
-
block_mid_x
)
<
line_height
/
2
:
center_close_num
+=
1
# 计算line左侧顶格数量是否大于2,是否顶格用abs(block['bbox_fs'][0] - line['bbox'][0]) < line_height/2 来判断
# 计算line左侧顶格数量是否大于2,是否顶格用abs(block['bbox_fs'][0] - line['bbox'][0]) < line_height/2 来判断
if
abs
(
block
[
'bbox_fs'
][
0
]
-
line
[
'bbox'
][
0
])
<
line_height
/
2
:
if
abs
(
block
[
'bbox_fs'
][
0
]
-
line
[
'bbox'
][
0
])
<
line_height
/
2
:
left_close_num
+=
1
left_close_num
+=
1
...
...
requirements.txt
View file @
6f571bb7
boto3
>=1.28.43
boto3
>=1.28.43
Brotli
>=1.1.0
Brotli
>=1.1.0
click
>=8.1.7
click
>=8.1.7
fast-langdetect
>=0.2.3
fast-langdetect
>=0.2.3
,<0.3.0
loguru
>=0.6.0
loguru
>=0.6.0
numpy
>=1.21.6,<2.0.0
numpy
>=1.21.6,<2.0.0
pydantic
>=2.7.2
pydantic
>=2.7.2
...
...
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