Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
OurBuilding Ambient Agents with LangGraph course is now available on LangChain Academy!
Open In ColabOpen on GitHub

BibTeX

BibTeX is a file format and reference management system commonly used in conjunction withLaTeX typesetting. It serves as a way to organize and store bibliographic information for academic and research documents.

BibTeX files have a.bib extension and consist of plain text entries representing references to various publications, such as books, articles, conference papers, theses, and more. EachBibTeX entry follows a specific structure and contains fields for different bibliographic details like author names, publication title, journal or book title, year of publication, page numbers, and more.

BibTeX files can also store the path to documents, such as.pdf files that can be retrieved.

Installation

First, you need to installbibtexparser andPyMuPDF.

%pip install--upgrade--quiet  bibtexparser pymupdf

Examples

BibtexLoader has these arguments:

  • file_path: the path of the.bib bibtex file
  • optionalmax_docs: default=None, i.e. not limit. Use it to limit number of retrieved documents.
  • optionalmax_content_chars: default=4000. Use it to limit the number of characters in a single document.
  • optionalload_extra_meta: default=False. By default only the most important fields from the bibtex entries:Published (publication year),Title,Authors,Summary,Journal,Keywords, andURL. If True, it will also try to load returnentry_id,note,doi, andlinks fields.
  • optionalfile_pattern: default=r'[^:]+\.pdf'. Regex pattern to find files in thefile entry. Default pattern supportsZotero flavour bibtex style and bare file path.
from langchain_community.document_loadersimport BibtexLoader
API Reference:BibtexLoader
# Create a dummy bibtex file and download a pdf.
import urllib.request

urllib.request.urlretrieve(
"https://www.fourmilab.ch/etexts/einstein/specrel/specrel.pdf","einstein1905.pdf"
)

bibtex_text="""
@article{einstein1915,
title={Die Feldgleichungen der Gravitation},
abstract={Die Grundgleichungen der Gravitation, die ich hier entwickeln werde, wurden von mir in einer Abhandlung: ,,Die formale Grundlage der allgemeinen Relativit{\"a}tstheorie`` in den Sitzungsberichten der Preu{\ss}ischen Akademie der Wissenschaften 1915 ver{\"o}ffentlicht.},
author={Einstein, Albert},
journal={Sitzungsberichte der K{\"o}niglich Preu{\ss}ischen Akademie der Wissenschaften},
volume={1915},
number={1},
pages={844--847},
year={1915},
doi={10.1002/andp.19163540702},
link={https://onlinelibrary.wiley.com/doi/abs/10.1002/andp.19163540702},
file={einstein1905.pdf}
}
"""
# save bibtex_text to biblio.bib file
withopen("./biblio.bib","w")asfile:
file.write(bibtex_text)
docs= BibtexLoader("./biblio.bib").load()
docs[0].metadata
{'id': 'einstein1915',
'published_year': '1915',
'title': 'Die Feldgleichungen der Gravitation',
'publication': 'Sitzungsberichte der K{"o}niglich Preu{\\ss}ischen Akademie der Wissenschaften',
'authors': 'Einstein, Albert',
'abstract': 'Die Grundgleichungen der Gravitation, die ich hier entwickeln werde, wurden von mir in einer Abhandlung: ,,Die formale Grundlage der allgemeinen Relativit{"a}tstheorie`` in den Sitzungsberichten der Preu{\\ss}ischen Akademie der Wissenschaften 1915 ver{"o}ffentlicht.',
'url': 'https://doi.org/10.1002/andp.19163540702'}
print(docs[0].page_content[:400])# all pages of the pdf content
ON THE ELECTRODYNAMICS OF MOVING
BODIES
By A. EINSTEIN
June 30, 1905
It is known that Maxwell’s electrodynamics—as usually understood at the
present time—when applied to moving bodies, leads to asymmetries which do
not appear to be inherent in the phenomena. Take, for example, the recipro-
cal electrodynamic action of a magnet and a conductor. The observable phe-
nomenon here depends only on the r

Related


[8]ページ先頭

©2009-2025 Movatter.jp