Microsoft PowerPoint는 Microsoft의 프레젠테이션 프로그램입니다.
이 문서는 Microsoft PowerPoint 문서를 다운스트림에서 사용할 수 있는 document format으로 로드하는 방법을 다룹니다. Unstructured를 로컬에서 설정하는 방법에 대한 자세한 지침은 필수 시스템 종속성 설정을 포함하여 이 가이드를 참조하세요.
# Install packages
pip install unstructured
pip install python-magic
pip install python-pptx
from langchain_community.document_loaders import UnstructuredPowerPointLoader

loader = UnstructuredPowerPointLoader("./example_data/fake-power-point.pptx")

data = loader.load()

data
[Document(page_content='Adding a Bullet Slide\n\nFind the bullet slide layout\n\nUse _TextFrame.text for first bullet\n\nUse _TextFrame.add_paragraph() for subsequent bullets\n\nHere is a lot of text!\n\nHere is some text in a text box!', metadata={'source': './example_data/fake-power-point.pptx'})]

Element 유지하기

내부적으로 Unstructured는 텍스트의 다양한 청크에 대해 서로 다른 “element”를 생성합니다. 기본적으로 이들을 결합하지만, mode="elements"를 지정하여 쉽게 분리를 유지할 수 있습니다.
loader = UnstructuredPowerPointLoader(
    "./example_data/fake-power-point.pptx", mode="elements"
)

data = loader.load()

data[0]
Document(page_content='Adding a Bullet Slide', metadata={'source': './example_data/fake-power-point.pptx', 'category_depth': 0, 'file_directory': './example_data', 'filename': 'fake-power-point.pptx', 'last_modified': '2023-12-19T13:42:18', 'page_number': 1, 'languages': ['eng'], 'filetype': 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'category': 'Title'})

Azure AI Document Intelligence 사용하기

Azure AI Document Intelligence (이전 명칭 Azure Form Recognizer)는 디지털 또는 스캔된 PDF, 이미지, Office 및 HTML 파일에서 텍스트(필기 포함), 표, 문서 구조(예: 제목, 섹션 제목 등) 및 키-값 쌍을 추출하는 머신러닝 기반 서비스입니다. Document Intelligence는 PDF, JPEG/JPG, PNG, BMP, TIFF, HEIF, DOCX, XLSX, PPTXHTML을 지원합니다.
Document Intelligence를 사용하는 현재 loader 구현은 페이지별로 콘텐츠를 통합하여 LangChain document로 변환할 수 있습니다. 기본 출력 형식은 markdown이며, 의미론적 문서 청킹을 위해 MarkdownHeaderTextSplitter와 쉽게 연결할 수 있습니다. 또한 mode="single" 또는 mode="page"를 사용하여 단일 페이지의 순수 텍스트를 반환하거나 페이지별로 분할된 문서를 반환할 수 있습니다.

전제 조건

3개의 preview 지역 중 하나(East US, West US2, West Europe)에 Azure AI Document Intelligence 리소스가 필요합니다 - 없는 경우 이 문서를 따라 생성하세요. loader에 매개변수로 <endpoint><key>를 전달해야 합니다.
pip install -qU  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()

Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I