o
    +wiN                     @   sB   d dl mZ d dlmZ d dlZG dd dZedZedZdS )    )absolute_import)utilsNc                   @   s4   e Zd ZdZdddZdddZdd Zd	d
 ZdS )CorpusLoaderu  Loader for corpora.
    For a complete list of corpora available in KoNLPy,
    refer to :ref:`corpora`.

    .. code-block:: python

        >>> from konlpy.corpus import kolaw
        >>> fids = kolaw.fileids()
        >>> fobj = kolaw.open(fids[0])
        >>> print fobj.read(140)
        대한민국헌법

        유구한 역사와 전통에 빛나는 우리 대한국민은 3·1운동으로 건립된 대한민국임시정부의 법통과 불의에 항거한 4·19민주이념을 계승하고, 조국의 민주개혁과 평화적 통일의 사명에 입각하여 정의·인도와 동포애로써 민족의 단결을 공고히 하고, 모든 사회적 폐습과 불의를 타파하며, 자율과 조화를 바 바
    Nc                 C   s   |st d|| _d S )Nz(You need to input the name of the corpus)	Exceptionname)selfr    r   J/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/konlpy/corpus.py__init__   s   
zCorpusLoader.__init__c                 C   s(   dt j| jf }|rd||f S d| S )zAbsolute path of corpus file.
        If ``filename`` is *None*, returns absolute path of corpus.

        :param filename: Name of a particular file in the corpus.
        z%s/data/corpus/%sz%s/%sz%s/)r   installpathr   )r   filenamebasedirr   r   r	   abspath   s   zCorpusLoader.abspathc                 C   s   t |  S )zList of file IDs in the corpus.)oslistdirr   )r   r   r   r	   fileids*   s   zCorpusLoader.fileidsc                 C   s   t | |S )zMethod to open a file in the corpus.
        Returns a file object.

        :param filename: Name of a particular file in the corpus.
        )r   load_txtr   )r   r   r   r   r	   open.   s   zCorpusLoader.open)N)__name__
__module____qualname____doc__r
   r   r   r   r   r   r   r	   r      s    

r   kolawkobill)
__future__r   konlpyr   r   r   r   r   r   r   r   r	   <module>   s   /