langchain_community.document_loaders.bibtex.BibtexLoader¶

class langchain_community.document_loaders.bibtex.BibtexLoader(file_path: str, *, parser: Optional[BibtexparserWrapper] = None, max_docs: Optional[int] = None, max_content_chars: Optional[int] = 4000, load_extra_metadata: bool = False, file_pattern: str = '[^:]+\\.pdf')[source]¶

Load a bibtex file.

Each document represents one entry from the bibtex file.

If a PDF file is present in the file bibtex field, the original PDF is loaded into the document text. If no such file entry is present, the abstract field is used instead.

Initialize the BibtexLoader.

Parameters
  • file_path (str) – Path to the bibtex file.

  • parser (Optional[BibtexparserWrapper]) – The parser to use. If None, a default parser is used.

  • max_docs (Optional[int]) – Max number of associated documents to load. Use -1 means no limit.

  • max_content_chars (Optional[int]) – Maximum number of characters to load from the PDF.

  • load_extra_metadata (bool) – Whether to load extra metadata from the PDF.

  • file_pattern (str) – Regex pattern to match the file name in the bibtex.

Methods

__init__(file_path, *[, parser, max_docs, ...])

Initialize the BibtexLoader.

alazy_load()

A lazy loader for Documents.

lazy_load()

Load bibtex file using bibtexparser and get the article texts plus the article metadata.

load()

Load data into Document objects.

load_and_split([text_splitter])

Load Documents and split into chunks.

__init__(file_path: str, *, parser: Optional[BibtexparserWrapper] = None, max_docs: Optional[int] = None, max_content_chars: Optional[int] = 4000, load_extra_metadata: bool = False, file_pattern: str = '[^:]+\\.pdf')[source]¶

Initialize the BibtexLoader.

Parameters
  • file_path (str) – Path to the bibtex file.

  • parser (Optional[BibtexparserWrapper]) – The parser to use. If None, a default parser is used.

  • max_docs (Optional[int]) – Max number of associated documents to load. Use -1 means no limit.

  • max_content_chars (Optional[int]) – Maximum number of characters to load from the PDF.

  • load_extra_metadata (bool) – Whether to load extra metadata from the PDF.

  • file_pattern (str) – Regex pattern to match the file name in the bibtex.

async alazy_load() AsyncIterator[Document]¶

A lazy loader for Documents.

Return type

AsyncIterator[Document]

lazy_load() Iterator[Document][source]¶

Load bibtex file using bibtexparser and get the article texts plus the article metadata. See https://bibtexparser.readthedocs.io/en/master/

Returns

a list of documents with the document.page_content in text format

Return type

Iterator[Document]

load() List[Document]¶

Load data into Document objects.

Return type

List[Document]

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

Load Documents and split into chunks. Chunks are returned as Documents.

Do not override this method. It should be considered to be deprecated!

Parameters

text_splitter (Optional[TextSplitter]) – TextSplitter instance to use for splitting documents. Defaults to RecursiveCharacterTextSplitter.

Returns

List of Documents.

Return type

List[Document]

Examples using BibtexLoader¶