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
058c349c
Unverified
Commit
058c349c
authored
Feb 27, 2025
by
Xiaomeng Zhao
Committed by
GitHub
Feb 27, 2025
Browse files
Merge pull request #1799 from myhloli/dev
refactor(ocr_mkcontent): optimize full-width character handling
parents
2629cadc
df1b8f59
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
5 deletions
+2
-5
magic_pdf/dict2md/ocr_mkcontent.py
magic_pdf/dict2md/ocr_mkcontent.py
+2
-5
No files found.
magic_pdf/dict2md/ocr_mkcontent.py
View file @
058c349c
...
...
@@ -138,12 +138,9 @@ def full_to_half(text: str) -> str:
result
=
[]
for
char
in
text
:
code
=
ord
(
char
)
# Full-width
ASCII variants (FF01-FF5E
)
if
0xFF
01
<=
code
<=
0xFF5E
:
# Full-width
letters and numbers (FF21-FF3A for A-Z, FF41-FF5A for a-z, FF10-FF19 for 0-9
)
if
(
0xFF
21
<=
code
<=
0xFF3A
)
or
(
0xFF41
<=
code
<=
0xFF5A
)
or
(
0xFF10
<=
code
<=
0xFF19
)
:
result
.
append
(
chr
(
code
-
0xFEE0
))
# Shift to ASCII range
# Full-width space
elif
code
==
0x3000
:
result
.
append
(
' '
)
else
:
result
.
append
(
char
)
return
''
.
join
(
result
)
...
...
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