H
commited on
Commit
·
eec0415
1
Parent(s):
9d25ba5
Fix pdfparser content confusion (#1700)
Browse files### What problem does this PR solve?
#1407 #1656
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
- deepdoc/parser/pdf_parser.py +2 -16
deepdoc/parser/pdf_parser.py
CHANGED
|
@@ -285,24 +285,10 @@ class RAGFlowPdfParser:
|
|
| 285 |
"page_number": pagenum} for b, t in bxs if b[0][0] <= b[1][0] and b[0][1] <= b[-1][1]],
|
| 286 |
self.mean_height[-1] / 3
|
| 287 |
)
|
| 288 |
-
|
| 289 |
-
# solve char content confusion
|
| 290 |
-
record_error_length, ct = 0, 0.001
|
| 291 |
-
for c in chars[0:128]:
|
| 292 |
-
ii = Recognizer.find_overlapped(c, bxs)
|
| 293 |
-
if ii is None:
|
| 294 |
-
continue
|
| 295 |
-
record_error_length += abs((bxs[ii]["bottom"] + bxs[ii]["top"] - c["bottom"] - c["top"]) / 2)
|
| 296 |
-
ct += 1
|
| 297 |
-
|
| 298 |
-
record_error_length = record_error_length / ct
|
| 299 |
-
for char in chars:
|
| 300 |
-
char["top"] -= record_error_length
|
| 301 |
-
char["bottom"] -= record_error_length
|
| 302 |
|
| 303 |
# merge chars in the same rect
|
| 304 |
-
for c in Recognizer.
|
| 305 |
-
chars, self.
|
| 306 |
ii = Recognizer.find_overlapped(c, bxs)
|
| 307 |
if ii is None:
|
| 308 |
self.lefted_chars.append(c)
|
|
|
|
| 285 |
"page_number": pagenum} for b, t in bxs if b[0][0] <= b[1][0] and b[0][1] <= b[-1][1]],
|
| 286 |
self.mean_height[-1] / 3
|
| 287 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
|
| 289 |
# merge chars in the same rect
|
| 290 |
+
for c in Recognizer.sort_Y_firstly(
|
| 291 |
+
chars, self.mean_height[pagenum - 1] // 4):
|
| 292 |
ii = Recognizer.find_overlapped(c, bxs)
|
| 293 |
if ii is None:
|
| 294 |
self.lefted_chars.append(c)
|