微软办公
微软办公 (opens in a new tab)生产力软件套件包括Microsoft Word、Microsoft Excel、Microsoft PowerPoint、Microsoft Outlook和Microsoft OneNote。它适用于Microsoft Windows和macOS操作系统。同时也适用于Android和iOS。
这涵盖了如何将常用的文件格式,包括DOCX、XLSX和PPTX文档加载到我们可以在下游使用的文档格式中。
使用AzureAIDocumentIntelligenceLoader加载DOCX、XLSX、PPTX
Azure AI文档智能 (opens in a new tab)(以前称为Azure表单识别)是一项基于机器学习的服务,从数字或扫描的PDF、图像、办公和HTML文件中提取文本(包括手写)、表格、文档结构(例如标题、章节标题等)和键值对。文档智能支持PDF、JPEG/JPG、PNG、BMP、TIFF、HEIF、DOCX、XLSX、PPTX和HTML。
这个使用文档智能的当前实现 (opens in a new tab)的加载程序可以将内容以页面为单位合并,并将其转换为LangChain文档。默认的输出格式是markdown,可以很容易地与MarkdownHeaderTextSplitter链接,用于语义文档划分。您还可以使用mode="single"或mode="page"以单页或按页拆分的形式返回纯文本。
先决条件
在3个预览区域之一拥有Azure AI文档智能资源:East US、West US2、West Europe - 如果没有,请按照此文档 (opens in a new tab)进行创建。您将会传递<endpoint>和<key>作为加载器的参数。
%pip install --upgrade --quiet langchain langchain-community azure-ai-documentintelligence
from langchain_community.document_loaders import AzureAIDocumentIntelligenceLoader
file_path = "<filepath>"
endpoint = "<endpoint>"
key = "<key>"
loader = AzureAIDocumentIntelligenceLoader(
api_endpoint=endpoint, api_key=key, file_path=file_path, api_model="prebuilt-layout"
)
documents = loader.load()