fix: When parsing the bold content in PDF, the result is duplicated. (#1729)
Browse files### What problem does this PR solve?
_fix: When parsing the bold content in PDF, the result is duplicated._
the detail: [When using OCR to recognize Chinese titles, the structure
appears to be
duplicated](https://github.com/infiniflow/ragflow/issues/1718)
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
deepdoc/parser/pdf_parser.py
CHANGED
@@ -952,7 +952,7 @@ class RAGFlowPdfParser:
|
|
952 |
fnm, str) else pdfplumber.open(BytesIO(fnm))
|
953 |
self.page_images = [p.to_image(resolution=72 * zoomin).annotated for i, p in
|
954 |
enumerate(self.pdf.pages[page_from:page_to])]
|
955 |
-
self.page_chars = [[{**c, 'top': max(0, c['top'] - 10), 'bottom': max(0, c['bottom'] - 10)} for c in page.chars if self._has_color(c)] for page in
|
956 |
self.pdf.pages[page_from:page_to]]
|
957 |
self.total_page = len(self.pdf.pages)
|
958 |
except Exception as e:
|
|
|
952 |
fnm, str) else pdfplumber.open(BytesIO(fnm))
|
953 |
self.page_images = [p.to_image(resolution=72 * zoomin).annotated for i, p in
|
954 |
enumerate(self.pdf.pages[page_from:page_to])]
|
955 |
+
self.page_chars = [[{**c, 'top': max(0, c['top'] - 10), 'bottom': max(0, c['bottom'] - 10)} for c in page.dedupe_chars().chars if self._has_color(c)] for page in
|
956 |
self.pdf.pages[page_from:page_to]]
|
957 |
self.total_page = len(self.pdf.pages)
|
958 |
except Exception as e:
|