
    Ng                     F    d dl mZ d dlmZ d dlmZ  G d de          ZdS )    )List)Document)
BaseLoaderc                   6    e Zd ZdZdefdZdee         fdZdS )GutenbergLoaderzLoad from `Gutenberg.org`.	file_pathc                     |                     d          st          d          |                    d          st          d          || _        dS )zInitialize with a file path.zhttps://www.gutenberg.orgz5file path must start with 'https://www.gutenberg.org'z.txtzfile path must end with '.txt'N)
startswith
ValueErrorendswithr   )selfr   s     j/var/www/html/ai-engine/env/lib/python3.11/site-packages/langchain_community/document_loaders/gutenberg.py__init__zGutenbergLoader.__init__   sY    ##$?@@ 	VTUUU!!&)) 	?=>>>"    returnc                     ddl m}  || j                  }d                    d |D                       }d| j        i}t	          ||          gS )z
Load file.r   )urlopenz

c                 R    g | ]$}t          |                    d                     %S )z	utf-8-sig)strdecode).0els     r   
<listcomp>z(GutenbergLoader.load.<locals>.<listcomp>   s,    KKKBC		+ 6 677KKKr   source)page_contentmetadata)urllib.requestr   r   joinr   )r   r   elementstextr   s        r   loadzGutenbergLoader.load   sg    ******74>**{{KK(KKKLLdn-dX>>>??r   N)	__name__
__module____qualname____doc__r   r   r   r   r!    r   r   r   r      s[        $$## # # # #@d8n @ @ @ @ @ @r   r   N)typingr   langchain_core.documentsr   )langchain_community.document_loaders.baser   r   r&   r   r   <module>r*      sy          - - - - - - @ @ @ @ @ @@ @ @ @ @j @ @ @ @ @r   