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
27c080a9
"vscode:/vscode.git/clone" did not exist on "df100ce5409fa52a113b1bfbb69f933021d8dd02"
Commit
27c080a9
authored
Mar 21, 2024
by
赵小蒙
Browse files
pipeline调整
parent
b94fd7f0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
1 deletion
+31
-1
magic_pdf/pipeline.py
magic_pdf/pipeline.py
+31
-1
No files found.
magic_pdf/pipeline.py
View file @
27c080a9
...
...
@@ -496,6 +496,35 @@ def ocr_pdf_intermediate_dict_to_markdown(jso: dict, debug_mode=False) -> dict:
return
jso
def
ocr_pdf_intermediate_dict_to_markdown_with_para
(
jso
:
dict
,
debug_mode
=
False
)
->
dict
:
if
debug_mode
:
pass
else
:
# 如果debug没开,则检测是否有needdrop字段
if
jso
.
get
(
"need_drop"
,
False
):
book_name
=
join_path
(
get_data_source
(
jso
),
jso
[
"file_id"
])
logger
.
info
(
f
"book_name is:
{
book_name
}
need drop"
,
file
=
sys
.
stderr
)
jso
[
"dropped"
]
=
True
return
jso
try
:
pdf_intermediate_dict
=
jso
[
"pdf_intermediate_dict"
]
# 将 pdf_intermediate_dict 解压
pdf_intermediate_dict
=
JsonCompressor
.
decompress_json
(
pdf_intermediate_dict
)
markdown_content
=
ocr_mk_mm_markdown_with_para
(
pdf_intermediate_dict
)
jso
[
"content"
]
=
markdown_content
logger
.
info
(
f
"book_name is:
{
get_data_source
(
jso
)
}
/
{
jso
[
'file_id'
]
}
,markdown content length is
{
len
(
markdown_content
)
}
"
,
file
=
sys
.
stderr
,
)
# 把无用的信息清空
jso
[
"doc_layout_result"
]
=
""
jso
[
"pdf_intermediate_dict"
]
=
""
jso
[
"pdf_meta"
]
=
""
except
Exception
as
e
:
jso
=
exception_handler
(
jso
,
e
)
return
jso
def
ocr_pdf_intermediate_dict_to_markdown_with_para_for_qa
(
jso
:
dict
,
debug_mode
=
False
)
->
dict
:
...
...
@@ -520,7 +549,8 @@ def ocr_pdf_intermediate_dict_to_markdown_with_para_for_qa(
)
# 把无用的信息清空
jso
[
"doc_layout_result"
]
=
""
jso
[
"pdf_intermediate_dict"
]
=
pdf_intermediate_dict
jso
[
"pdf_intermediate_dict"
]
=
""
jso
[
"mid_json_ocr"
]
=
pdf_intermediate_dict
jso
[
"pdf_meta"
]
=
""
except
Exception
as
e
:
jso
=
exception_handler
(
jso
,
e
)
...
...
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