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
4b8dbd7c
Commit
4b8dbd7c
authored
Mar 29, 2024
by
赵小蒙
Browse files
ocr_pdf_intermediate_dict_to_markdown_with_para支持mm和nlp双模式
parent
d6a5724b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
magic_pdf/pipeline_ocr.py
magic_pdf/pipeline_ocr.py
+7
-3
No files found.
magic_pdf/pipeline_ocr.py
View file @
4b8dbd7c
...
@@ -41,7 +41,7 @@ def ocr_pdf_intermediate_dict_to_markdown(jso: dict, debug_mode=False) -> dict:
...
@@ -41,7 +41,7 @@ def ocr_pdf_intermediate_dict_to_markdown(jso: dict, debug_mode=False) -> dict:
return
jso
return
jso
def
ocr_pdf_intermediate_dict_to_markdown_with_para
(
jso
:
dict
,
debug_mode
=
False
)
->
dict
:
def
ocr_pdf_intermediate_dict_to_markdown_with_para
(
jso
:
dict
,
mode
,
debug_mode
=
False
)
->
dict
:
if
debug_mode
:
if
debug_mode
:
pass
pass
else
:
# 如果debug没开,则检测是否有needdrop字段
else
:
# 如果debug没开,则检测是否有needdrop字段
...
@@ -54,8 +54,12 @@ def ocr_pdf_intermediate_dict_to_markdown_with_para(jso: dict, debug_mode=False)
...
@@ -54,8 +54,12 @@ def ocr_pdf_intermediate_dict_to_markdown_with_para(jso: dict, debug_mode=False)
pdf_intermediate_dict
=
jso
[
"pdf_intermediate_dict"
]
pdf_intermediate_dict
=
jso
[
"pdf_intermediate_dict"
]
# 将 pdf_intermediate_dict 解压
# 将 pdf_intermediate_dict 解压
pdf_intermediate_dict
=
JsonCompressor
.
decompress_json
(
pdf_intermediate_dict
)
pdf_intermediate_dict
=
JsonCompressor
.
decompress_json
(
pdf_intermediate_dict
)
# markdown_content = ocr_mk_mm_markdown_with_para(pdf_intermediate_dict)
if
mode
==
"mm"
:
markdown_content
=
ocr_mk_mm_markdown_with_para
(
pdf_intermediate_dict
)
elif
mode
==
"nlp"
:
markdown_content
=
ocr_mk_nlp_markdown_with_para
(
pdf_intermediate_dict
)
markdown_content
=
ocr_mk_nlp_markdown_with_para
(
pdf_intermediate_dict
)
jso
[
"content"
]
=
markdown_content
jso
[
"content"
]
=
markdown_content
logger
.
info
(
logger
.
info
(
f
"book_name is:
{
get_data_source
(
jso
)
}
/
{
jso
[
'file_id'
]
}
,markdown content length is
{
len
(
markdown_content
)
}
"
,
f
"book_name is:
{
get_data_source
(
jso
)
}
/
{
jso
[
'file_id'
]
}
,markdown content length is
{
len
(
markdown_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