mirror of
https://github.com/DS4SD/docling.git
synced 2025-07-30 14:04:27 +00:00
Update imports for docling_parse.pdf_parser_v1
Signed-off-by: Christoph Auer <cau@zurich.ibm.com>
This commit is contained in:
parent
b8796e6705
commit
9204d5e79f
@ -6,7 +6,7 @@ from typing import Iterable, List, Optional, Union
|
||||
|
||||
import pypdfium2 as pdfium
|
||||
from docling_core.types.doc import BoundingBox, CoordOrigin, Size
|
||||
from docling_parse.docling_parse import pdf_parser
|
||||
from docling_parse.docling_parse import pdf_parser_v1
|
||||
from PIL import Image, ImageDraw
|
||||
from pypdfium2 import PdfPage
|
||||
|
||||
@ -19,7 +19,7 @@ _log = logging.getLogger(__name__)
|
||||
|
||||
class DoclingParsePageBackend(PdfPageBackend):
|
||||
def __init__(
|
||||
self, parser: pdf_parser, document_hash: str, page_no: int, page_obj: PdfPage
|
||||
self, parser: pdf_parser_v1, document_hash: str, page_no: int, page_obj: PdfPage
|
||||
):
|
||||
self._ppage = page_obj
|
||||
parsed_page = parser.parse_pdf_from_key_on_page(document_hash, page_no)
|
||||
@ -192,7 +192,7 @@ class DoclingParseDocumentBackend(PdfDocumentBackend):
|
||||
super().__init__(in_doc, path_or_stream)
|
||||
|
||||
self._pdoc = pdfium.PdfDocument(self.path_or_stream)
|
||||
self.parser = pdf_parser()
|
||||
self.parser = pdf_parser_v1()
|
||||
|
||||
success = False
|
||||
if isinstance(self.path_or_stream, BytesIO):
|
||||
|
@ -26,7 +26,7 @@ class DoclingParseV2PageBackend(PdfPageBackend):
|
||||
self._ppage = page_obj
|
||||
parsed_page = parser.parse_pdf_from_key_on_page(document_hash, page_no)
|
||||
|
||||
self.valid = "pages" in parsed_page and len(parsed_page["pages"])==1
|
||||
self.valid = "pages" in parsed_page and len(parsed_page["pages"]) == 1
|
||||
if self.valid:
|
||||
self._dpage = parsed_page["pages"][0]
|
||||
else:
|
||||
@ -223,12 +223,12 @@ class DoclingParseV2DocumentBackend(PdfDocumentBackend):
|
||||
)
|
||||
|
||||
def page_count(self) -> int:
|
||||
#return len(self._pdoc) # To be replaced with docling-parse API
|
||||
# return len(self._pdoc) # To be replaced with docling-parse API
|
||||
|
||||
len_1 = len(self._pdoc)
|
||||
len_2 = self.parser.number_of_pages(self.document_hash)
|
||||
|
||||
if len_1!=len_2:
|
||||
if len_1 != len_2:
|
||||
_log.error(f"Inconsistent number of pages: {len_1}!={len_2}")
|
||||
|
||||
return len_2
|
||||
|
Loading…
Reference in New Issue
Block a user