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
0ebbfa5c
Unverified
Commit
0ebbfa5c
authored
Jan 09, 2025
by
Xiaomeng Zhao
Committed by
GitHub
Jan 09, 2025
Browse files
Merge pull request #1468 from myhloli/dev
fix(language): enhance language detection and text processing
parents
cc859604
869cf0a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
0 deletions
+3
-0
magic_pdf/libs/language.py
magic_pdf/libs/language.py
+3
-0
No files found.
magic_pdf/libs/language.py
View file @
0ebbfa5c
...
...
@@ -16,11 +16,14 @@ def detect_lang(text: str) -> str:
if
len
(
text
)
==
0
:
return
""
text
=
text
.
replace
(
"
\n
"
,
""
)
try
:
lang_upper
=
detect_language
(
text
)
except
:
html_no_ctrl_chars
=
''
.
join
([
l
for
l
in
text
if
unicodedata
.
category
(
l
)[
0
]
not
in
[
'C'
,
]])
lang_upper
=
detect_language
(
html_no_ctrl_chars
)
try
:
lang
=
lang_upper
.
lower
()
except
:
...
...
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