langchain_community.document_loaders.llmsherpa.LLMSherpaFileLoader

class langchain_community.document_loaders.llmsherpa.LLMSherpaFileLoader(file_path: Union[str, Path], new_indent_parser: bool = True, apply_ocr: bool = True, strategy: str = 'chunks', llmsherpa_api_url: str = 'https://readers.llmsherpa.com/api/document/developer/parseDocument?renderFormat=all')[source]

使用`LLMSherpa`加载文档。

LLMSherpaFileLoader使用LayoutPDFReader,它是LLMSherpa库的一部分。 该工具旨在解析PDF文件同时保留其布局信息, 这在使用大多数PDF转文本解析器时经常会丢失。

from langchain_community.document_loaders.llmsherpa import LLMSherpaFileLoader

loader = LLMSherpaFileLoader(

“example.pdf”, strategy=”chunks”, llmsherpa_api_url=”http://localhost:5010/api/parseDocument?renderFormat=all”,

) docs = loader.load()

使用文件路径进行初始化。

Methods

__init__(file_path[, new_indent_parser, ...])

使用文件路径进行初始化。

alazy_load()

一个用于文档的惰性加载器。

aload()

将数据加载到文档对象中。

lazy_load()

加载文件。

load()

将数据加载到文档对象中。

load_and_split([text_splitter])

加载文档并分割成块。块作为文档返回。

Parameters
  • file_path (Union[str, Path]) –

  • new_indent_parser (bool) –

  • apply_ocr (bool) –

  • strategy (str) –

  • llmsherpa_api_url (str) –

__init__(file_path: Union[str, Path], new_indent_parser: bool = True, apply_ocr: bool = True, strategy: str = 'chunks', llmsherpa_api_url: str = 'https://readers.llmsherpa.com/api/document/developer/parseDocument?renderFormat=all')[source]

使用文件路径进行初始化。

Parameters
  • file_path (Union[str, Path]) –

  • new_indent_parser (bool) –

  • apply_ocr (bool) –

  • strategy (str) –

  • llmsherpa_api_url (str) –

async alazy_load() AsyncIterator[Document]

一个用于文档的惰性加载器。

Return type

AsyncIterator[Document]

async aload() List[Document]

将数据加载到文档对象中。

Return type

List[Document]

lazy_load() Iterator[Document][source]

加载文件。

Return type

Iterator[Document]

load() List[Document]

将数据加载到文档对象中。

Return type

List[Document]

load_and_split(text_splitter: Optional[TextSplitter] = None) List[Document]

加载文档并分割成块。块作为文档返回。

不要覆盖此方法。应该被视为已弃用!

参数:
text_splitter: 用于分割文档的TextSplitter实例。

默认为RecursiveCharacterTextSplitter。

返回:

文档列表。

Parameters

text_splitter (Optional[TextSplitter]) –

Return type

List[Document]

Examples using LLMSherpaFileLoader