mirror of
https://github.com/DS4SD/docling.git
synced 2025-12-08 20:58:11 +00:00
Test all backends, fixes
Signed-off-by: Christoph Auer <cau@zurich.ibm.com>
This commit is contained in:
@@ -3,7 +3,7 @@ from pathlib import Path
|
||||
from docling_core.types.doc import CodeItem, TextItem
|
||||
from docling_core.types.doc.labels import CodeLanguageLabel, DocItemLabel
|
||||
|
||||
from docling.backend.docling_parse_v2_backend import DoclingParseV2DocumentBackend
|
||||
from docling.backend.docling_parse_v2_backend import DoclingParseV4DocumentBackend
|
||||
from docling.datamodel.base_models import InputFormat
|
||||
from docling.datamodel.document import ConversionResult
|
||||
from docling.datamodel.pipeline_options import PdfPipelineOptions
|
||||
@@ -24,7 +24,6 @@ def get_converter():
|
||||
converter = DocumentConverter(
|
||||
format_options={
|
||||
InputFormat.PDF: PdfFormatOption(
|
||||
backend=DoclingParseV2DocumentBackend,
|
||||
pipeline_cls=StandardPdfPipeline,
|
||||
pipeline_options=pipeline_options,
|
||||
)
|
||||
|
||||
@@ -2,7 +2,7 @@ from pathlib import Path
|
||||
|
||||
from docling_core.types.doc import PictureClassificationData
|
||||
|
||||
from docling.backend.docling_parse_v2_backend import DoclingParseV2DocumentBackend
|
||||
from docling.backend.docling_parse_v2_backend import DoclingParseV4DocumentBackend
|
||||
from docling.datamodel.base_models import InputFormat
|
||||
from docling.datamodel.document import ConversionResult
|
||||
from docling.datamodel.pipeline_options import PdfPipelineOptions
|
||||
@@ -26,7 +26,6 @@ def get_converter():
|
||||
converter = DocumentConverter(
|
||||
format_options={
|
||||
InputFormat.PDF: PdfFormatOption(
|
||||
backend=DoclingParseV2DocumentBackend,
|
||||
pipeline_cls=StandardPdfPipeline,
|
||||
pipeline_options=pipeline_options,
|
||||
)
|
||||
|
||||
@@ -34,7 +34,7 @@ def get_converter():
|
||||
converter = DocumentConverter(
|
||||
format_options={
|
||||
InputFormat.PDF: PdfFormatOption(
|
||||
pipeline_options=pipeline_options, backend=DoclingParseV4DocumentBackend
|
||||
pipeline_options=pipeline_options,
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -45,7 +45,6 @@ def get_converter(ocr_options: OcrOptions):
|
||||
format_options={
|
||||
InputFormat.PDF: PdfFormatOption(
|
||||
pipeline_options=pipeline_options,
|
||||
backend=DoclingParseV4DocumentBackend,
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -31,7 +31,7 @@ def converter():
|
||||
converter = DocumentConverter(
|
||||
format_options={
|
||||
InputFormat.PDF: PdfFormatOption(
|
||||
pipeline_options=pipeline_options, backend=DoclingParseV4DocumentBackend
|
||||
pipeline_options=pipeline_options,
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -3,7 +3,10 @@ from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from docling.backend.docling_parse_backend import DoclingParseDocumentBackend
|
||||
from docling.backend.docling_parse_v2_backend import DoclingParseV2DocumentBackend
|
||||
from docling.backend.docling_parse_v4_backend import DoclingParseV4DocumentBackend
|
||||
from docling.backend.pypdfium2_backend import PyPdfiumDocumentBackend
|
||||
from docling.datamodel.base_models import ConversionStatus, InputFormat
|
||||
from docling.datamodel.document import ConversionResult
|
||||
from docling.datamodel.pipeline_options import (
|
||||
@@ -33,7 +36,6 @@ def get_converters_with_table_options():
|
||||
format_options={
|
||||
InputFormat.PDF: PdfFormatOption(
|
||||
pipeline_options=pipeline_options,
|
||||
backend=DoclingParseV4DocumentBackend,
|
||||
)
|
||||
}
|
||||
)
|
||||
@@ -137,3 +139,29 @@ def test_ocr_coverage_threshold(test_doc_path):
|
||||
|
||||
# this should have generated no results, since we set a very high threshold
|
||||
assert len(doc_result.document.texts) == 0
|
||||
|
||||
|
||||
def test_parser_backends(test_doc_path):
|
||||
pipeline_options = PdfPipelineOptions()
|
||||
pipeline_options.do_ocr = False
|
||||
pipeline_options.do_table_structure = False
|
||||
|
||||
for backend_t in [
|
||||
DoclingParseV4DocumentBackend,
|
||||
DoclingParseV2DocumentBackend,
|
||||
DoclingParseDocumentBackend,
|
||||
PyPdfiumDocumentBackend,
|
||||
]:
|
||||
converter = DocumentConverter(
|
||||
format_options={
|
||||
InputFormat.PDF: PdfFormatOption(
|
||||
pipeline_options=pipeline_options,
|
||||
backend=backend_t,
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
test_doc_path = Path("./tests/data/pdf/code_and_formula.pdf")
|
||||
doc_result: ConversionResult = converter.convert(test_doc_path)
|
||||
|
||||
assert doc_result.status == ConversionStatus.SUCCESS
|
||||
|
||||
Reference in New Issue
Block a user