
    Ng
                     B    d dl Z d dlmZ d dlmZ  G d de          ZdS )    N)List)UnstructuredFileLoaderc                       e Zd ZdZdefdZdS )UnstructuredPowerPointLoaderab  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
    returnc                    ddl m} ddlm}m} t          d |                    d          D                       }	 dd l} || j                  |j	        k    }nJ# t          $ r= t          j                            t          | j                            \  }}|dk    }Y nw xY w|r|dk     rt          d| d	          |rdd
lm}	  |	dd| j        i| j        S ddlm}
  |
dd| j        i| j        S )Nr   )__version__)FileTypedetect_filetypec                 ,    g | ]}t          |          S  )int).0xs     k/var/www/html/ai-engine/env/lib/python3.11/site-packages/langchain_community/document_loaders/powerpoint.py
<listcomp>z>UnstructuredPowerPointLoader._get_elements.<locals>.<listcomp>%   s    AAASVVAAA    .z.ppt)r         z You are on unstructured version z{. Partitioning .ppt files is only supported in unstructured>=0.4.11. Please upgrade the unstructured package and try again.)partition_pptfilename)partition_pptxr   )unstructured.__version__r	    unstructured.file_utils.filetyper
   r   tuplesplitmagic	file_pathPPTImportErrorospathsplitextstr
ValueErrorunstructured.partition.pptr   unstructured_kwargsunstructured.partition.pptxr   )self__unstructured_version__r
   r   unstructured_versionr   is_ppt_	extensionr   r   s              r   _get_elementsz*UnstructuredPowerPointLoader._get_elements    s   TTTTTTNNNNNNNN$AA5;;C@@AAA 
  
	)LLL$_T^44DFF 	) 	) 	)7++C,?,?@@LAy&(FFF	)  	*Z77I3K I I I    	W@@@@@@ =UU$.UD<TUUUBBBBBB!>VV4>VT=UVVVs   A AB! B!N)__name__
__module____qualname____doc__r   r0   r   r   r   r   r      s@         0 Wt  W  W  W  W  W  Wr   r   )r"   typingr   1langchain_community.document_loaders.unstructuredr   r   r   r   r   <module>r7      sq    				       T T T T T T9W 9W 9W 9W 9W#9 9W 9W 9W 9W 9Wr   