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
23c8436e
Unverified
Commit
23c8436e
authored
Nov 21, 2024
by
Xiaomeng Zhao
Committed by
GitHub
Nov 21, 2024
Browse files
Merge pull request #1047 from myhloli/dev
fix(ocr_mkcontent): improve hyphen handling at line ends
parents
a8ea5d4a
a07007e5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
magic_pdf/dict2md/ocr_mkcontent.py
magic_pdf/dict2md/ocr_mkcontent.py
+4
-3
No files found.
magic_pdf/dict2md/ocr_mkcontent.py
View file @
23c8436e
...
...
@@ -141,9 +141,10 @@ def merge_para_with_text(para_block):
span_type
=
span
[
'type'
]
if
span_type
==
ContentType
.
Text
:
line_text
+=
span
[
'content'
].
strip
()
if
line_text
!=
''
:
line_lang
=
detect_lang
(
line_text
)
for
span
in
line
[
'spans'
]:
for
j
,
span
in
enumerate
(
line
[
'spans'
]
)
:
span_type
=
span
[
'type'
]
content
=
''
...
...
@@ -164,8 +165,8 @@ def merge_para_with_text(para_block):
para_text
+=
f
'
{
content
}
'
else
:
if
span_type
in
[
ContentType
.
Text
,
ContentType
.
InlineEquation
]:
# 如果
是前一行
带有-连字符,那么末尾不应该加空格
if
__is_hyphen_at_line_end
(
content
):
# 如果
span是line的最后一个且末尾
带有-连字符,那么末尾不应该加空格
,同时应该把-删除
if
j
==
len
(
line
[
'spans'
])
-
1
and
__is_hyphen_at_line_end
(
content
):
para_text
+=
content
[:
-
1
]
elif
len
(
content
)
==
1
and
content
not
in
[
'A'
,
'I'
,
'a'
,
'i'
]
and
not
content
.
isdigit
():
para_text
+=
content
...
...
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