mirror of
https://github.com/hwchase17/langchain
synced 2024-11-06 03:20:49 +00:00
357d808484
Co-authored-by: Tim Asp <707699+timothyasp@users.noreply.github.com>
56 lines
1.5 KiB
Python
56 lines
1.5 KiB
Python
from pathlib import Path
|
|
|
|
from langchain.document_loaders import (
|
|
PDFMinerLoader,
|
|
PyMuPDFLoader,
|
|
UnstructuredPDFLoader,
|
|
)
|
|
|
|
|
|
def test_unstructured_pdf_loader() -> None:
|
|
"""Test unstructured loader."""
|
|
file_path = Path(__file__).parent.parent / "examples/hello.pdf"
|
|
loader = UnstructuredPDFLoader(str(file_path))
|
|
docs = loader.load()
|
|
|
|
assert len(docs) == 1
|
|
|
|
|
|
def test_pdfminer_loader() -> None:
|
|
"""Test PDFMiner loader."""
|
|
file_path = Path(__file__).parent.parent / "examples/hello.pdf"
|
|
loader = PDFMinerLoader(str(file_path))
|
|
docs = loader.load()
|
|
|
|
assert len(docs) == 1
|
|
|
|
file_path = Path(__file__).parent.parent / "examples/layout-parser-paper.pdf"
|
|
loader = PDFMinerLoader(str(file_path))
|
|
|
|
docs = loader.load()
|
|
assert len(docs) == 1
|
|
|
|
|
|
def test_pymupdf_loader() -> None:
|
|
"""Test PyMuPDF loader."""
|
|
file_path = Path(__file__).parent.parent / "examples/hello.pdf"
|
|
loader = PyMuPDFLoader(str(file_path))
|
|
|
|
docs = loader.load()
|
|
assert len(docs) == 1
|
|
|
|
file_path = Path(__file__).parent.parent / "examples/layout-parser-paper.pdf"
|
|
loader = PyMuPDFLoader(str(file_path))
|
|
|
|
docs = loader.load()
|
|
assert len(docs) == 16
|
|
assert loader.web_path is None
|
|
|
|
web_path = "https://people.sc.fsu.edu/~jpeterson/hello_world.pdf"
|
|
loader = PyMuPDFLoader(web_path)
|
|
|
|
docs = loader.load()
|
|
assert loader.web_path == web_path
|
|
assert loader.file_path != web_path
|
|
assert len(docs) == 1
|