Skip to main content

Grobid

GROBID 是一个用于提取、解析和重构原始文档的机器学习库。

它旨在并预计用于解析学术论文,在这方面表现尤为出色。

注意: 如果提供给 Grobid 的文章是大型文档(例如,论文),超过一定数量的元素, 它们可能无法被处理。

本页面介绍如何使用 Grobid 解析 LangChain 的文章。

安装

grobid 的安装详细描述在 https://grobid.readthedocs.io/en/latest/Install-Grobid/。 然而,通过 docker 容器运行 grobid 可能更简单且麻烦更少, 如 这里 所述。

在LangChain中使用Grobid

一旦Grobid安装并运行(您可以通过访问http://localhost:8070来检查), 您就可以开始使用了。

您现在可以使用GrobidParser来生成文档

from langchain_community.document_loaders.parsers import GrobidParser
from langchain_community.document_loaders.generic import GenericLoader

#Produce chunks from article paragraphs
loader = GenericLoader.from_filesystem(
"/Users/31treehaus/Desktop/Papers/",
glob="*",
suffixes=[".pdf"],
parser= GrobidParser(segment_sentences=False)
)
docs = loader.load()

#Produce chunks from article sentences
loader = GenericLoader.from_filesystem(
"/Users/31treehaus/Desktop/Papers/",
glob="*",
suffixes=[".pdf"],
parser= GrobidParser(segment_sentences=True)
)
docs = loader.load()

块元数据将包括边界框。尽管这些解析起来有点奇怪, 但它们在 https://grobid.readthedocs.io/en/latest/Coordinates-in-PDF/ 中有解释。


Was this page helpful?


You can also leave detailed feedback on GitHub.

扫我,入群扫我,找书