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
29c61a97
Unverified
Commit
29c61a97
authored
Nov 04, 2024
by
Xiaomeng Zhao
Committed by
GitHub
Nov 04, 2024
Browse files
Merge pull request #857 from myhloli/dev
fix(merge_text): add ligature replacement functionality #305 #241
parents
d640c43c
bd755962
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
0 deletions
+12
-0
magic_pdf/dict2md/ocr_mkcontent.py
magic_pdf/dict2md/ocr_mkcontent.py
+12
-0
No files found.
magic_pdf/dict2md/ocr_mkcontent.py
View file @
29c61a97
...
@@ -119,6 +119,16 @@ def detect_language(text):
...
@@ -119,6 +119,16 @@ def detect_language(text):
return
'empty'
return
'empty'
# 连写字符拆分
def
__replace_ligatures
(
text
:
str
):
text
=
re
.
sub
(
r
'fi'
,
'fi'
,
text
)
# 替换 fi 连写符
text
=
re
.
sub
(
r
'fl'
,
'fl'
,
text
)
# 替换 fl 连写符
text
=
re
.
sub
(
r
'ff'
,
'ff'
,
text
)
# 替换 ff 连写符
text
=
re
.
sub
(
r
'ffi'
,
'ffi'
,
text
)
# 替换 ffi 连写符
text
=
re
.
sub
(
r
'ffl'
,
'ffl'
,
text
)
# 替换 ffl 连写符
return
text
def
merge_para_with_text
(
para_block
):
def
merge_para_with_text
(
para_block
):
para_text
=
''
para_text
=
''
for
i
,
line
in
enumerate
(
para_block
[
'lines'
]):
for
i
,
line
in
enumerate
(
para_block
[
'lines'
]):
...
@@ -166,6 +176,8 @@ def merge_para_with_text(para_block):
...
@@ -166,6 +176,8 @@ def merge_para_with_text(para_block):
para_text
+=
content
para_text
+=
content
else
:
else
:
continue
continue
# 连写字符拆分
para_text
=
__replace_ligatures
(
para_text
)
return
para_text
return
para_text
...
...
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