Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pdf-miner
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Qin Kaijie
pdf-miner
Commits
dbe79ba1
Commit
dbe79ba1
authored
Mar 22, 2024
by
赵小蒙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ocr_mk_mm_markdown_with_para_and_pagination逻辑更新
parent
f36c2656
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
19 deletions
+20
-19
ocr_mkcontent.py
magic_pdf/dict2md/ocr_mkcontent.py
+20
-19
No files found.
magic_pdf/dict2md/ocr_mkcontent.py
View file @
dbe79ba1
...
@@ -99,28 +99,29 @@ def ocr_mk_mm_markdown_with_para_and_pagination(pdf_info_dict: dict):
...
@@ -99,28 +99,29 @@ def ocr_mk_mm_markdown_with_para_and_pagination(pdf_info_dict: dict):
markdown_with_para_and_pagination
=
[]
markdown_with_para_and_pagination
=
[]
for
page_no
,
page_info
in
pdf_info_dict
.
items
():
for
page_no
,
page_info
in
pdf_info_dict
.
items
():
page_markdown
=
[]
page_markdown
=
[]
paras
=
page_info
.
get
(
"para_blocks"
)
paras
_of_layout
=
page_info
.
get
(
"para_blocks"
)
if
not
paras
:
if
not
paras
_of_layout
:
continue
continue
for
para
in
paras
:
for
paras
in
paras_of_layout
:
para_text
=
''
for
para
in
paras
:
for
line
in
para
:
para_text
=
''
for
span
in
line
[
'spans'
]:
for
line
in
para
:
span_type
=
span
.
get
(
'type'
)
for
span
in
line
[
'spans'
]:
if
span_type
==
ContentType
.
Text
:
span_type
=
span
.
get
(
'type'
)
content
=
split_long_words
(
span
[
'content'
])
if
span_type
==
ContentType
.
Text
:
# content = span['content']
content
=
split_long_words
(
span
[
'content'
])
elif
span_type
==
ContentType
.
InlineEquation
:
# content = span['content']
content
=
f
"${span['content']}$"
elif
span_type
==
ContentType
.
InlineEquation
:
elif
span_type
==
ContentType
.
InterlineEquation
:
content
=
f
"${span['content']}$"
content
=
f
"
\n
$$
\n
{span['content']}
\n
$$
\n
"
elif
span_type
==
ContentType
.
InterlineEquation
:
elif
span_type
in
[
ContentType
.
Image
,
ContentType
.
Table
]:
content
=
f
"
\n
$$
\n
{span['content']}
\n
$$
\n
"
content
=
f
"
\n
})
\n
"
elif
span_type
in
[
ContentType
.
Image
,
ContentType
.
Table
]:
para_text
+=
content
+
' '
content
=
f
"
\n
})
\n
"
page_markdown
.
append
(
para_text
.
strip
()
+
' '
)
para_text
+=
content
+
' '
page_markdown
.
append
(
para_text
.
strip
()
+
' '
)
markdown_with_para_and_pagination
.
append
({
markdown_with_para_and_pagination
.
append
({
'page_no'
:
page_no
,
'page_no'
:
page_no
,
'md'
:
'
\n\n
'
.
join
(
page_markdown
)
'md
_content
'
:
'
\n\n
'
.
join
(
page_markdown
)
})
})
return
markdown_with_para_and_pagination
return
markdown_with_para_and_pagination
...
...
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