Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix pdf_paser char content confusion #1462

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions deepdoc/parser/pdf_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,15 @@ def __ocr(self, pagenum, img, chars, ZM=3):
)

# solve char content confusion
record_error_length = 0
record_error_length, ct = 0, 1
for c in chars[0:128]:
ii = Recognizer.find_overlapped(c, bxs)
if ii is None:
continue
record_error_length += abs((bxs[ii]["bottom"] + bxs[ii]["bottom"] - c["bottom"] - c["top"]) / 2)
record_error_length += abs((bxs[ii]["bottom"] + bxs[ii]["top"] - c["bottom"] - c["top"]) / 2)
ct += 1

record_error_length = record_error_length / 128
record_error_length = record_error_length / ct
for char in chars:
char["top"] -= record_error_length
char["bottom"] -= record_error_length
Expand Down