a
    bŠÝgš  ã                   @   sH   d Z ddlmZ ddlmZmZmZ ddlmZm	Z	 G dd„ deƒZ
dS )zLoads rich text files.é    )ÚPath)ÚAnyÚListÚUnion)ÚUnstructuredFileLoaderÚvalidate_unstructured_versionc                       sB   e Zd ZdZd	eeef eedœ‡ fdd„Ze	dœdd„Z
‡  ZS )
ÚUnstructuredRTFLoadera  Load `RTF` files using `Unstructured`.

    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 UnstructuredRTFLoader

    loader = UnstructuredRTFLoader(
        "example.rtf", mode="elements", strategy="fast",
    )
    docs = loader.load()

    References
    ----------
    https://unstructured-io.github.io/unstructured/bricks.html#partition-rtf
    Úsingle)Ú	file_pathÚmodeÚunstructured_kwargsc                    s,   t |ƒ}tdƒ tƒ jf ||dœ|¤Ž dS )aS  
        Initialize with a file path.

        Args:
            file_path: The path to the file to load.
            mode: The mode to use for partitioning. See unstructured for details.
                Defaults to "single".
            **unstructured_kwargs: Additional keyword arguments to pass
                to unstructured.
        z0.5.12)r
   r   N)Ústrr   ÚsuperÚ__init__)Úselfr
   r   r   ©Ú	__class__© úv/var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/site-packages/langchain_community/document_loaders/rtf.pyr   $   s    zUnstructuredRTFLoader.__init__)Úreturnc                 C   s"   ddl m} |f d| ji| j¤ŽS )Nr   )Úpartition_rtfÚfilename)Zunstructured.partition.rtfr   r
   r   )r   r   r   r   r   Ú_get_elements8   s    z#UnstructuredRTFLoader._get_elements)r	   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   Ú__classcell__r   r   r   r   r      s    ý
ür   N)r   Úpathlibr   Útypingr   r   r   Z1langchain_community.document_loaders.unstructuredr   r   r   r   r   r   r   Ú<module>   s   