[docs]classUnstructuredPowerPointLoader(UnstructuredFileLoader):"""Load `Microsoft PowerPoint` files using `Unstructured`. Works with both .ppt and .pptx files. You can run the loader in one of two modes: "single" and "elements". If you use "single" mode, the document will be returned as a single langchain Document object. If you use "elements" mode, the unstructured library will split the document into elements such as Title and NarrativeText. You can pass in additional unstructured kwargs after mode to apply different unstructured settings. Examples -------- from langchain_community.document_loaders import UnstructuredPowerPointLoader loader = UnstructuredPowerPointLoader( "example.pptx", mode="elements", strategy="fast", ) docs = loader.load() References ---------- https://unstructured-io.github.io/unstructured/bricks.html#partition-pptx """def_get_elements(self)->List:fromunstructured.__version__import__version__as__unstructured_version__fromunstructured.file_utils.filetypeimportFileType,detect_filetypeunstructured_version=tuple([int(x)forxin__unstructured_version__.split(".")])# NOTE(MthwRobinson) - magic will raise an import error if the libmagic# system dependency isn't installed. If it's not installed, we'll just# check the file extensiontry:importmagic# noqa: F401is_ppt=detect_filetype(self.file_path)==FileType.PPTexceptImportError:_,extension=os.path.splitext(str(self.file_path))is_ppt=extension==".ppt"ifis_pptandunstructured_version<(0,4,11):raiseValueError(f"You are on unstructured version {__unstructured_version__}. ""Partitioning .ppt files is only supported in unstructured>=0.4.11. ""Please upgrade the unstructured package and try again.")ifis_ppt:fromunstructured.partition.pptimportpartition_pptreturnpartition_ppt(filename=self.file_path,**self.unstructured_kwargs)else:fromunstructured.partition.pptximportpartition_pptxreturnpartition_pptx(filename=self.file_path,**self.unstructured_kwargs)