o
    qi(                     @   s:   d Z ddlmZmZmZ ddlmZmZ G dd dZdS )z&A minimal module to parse CoNLL files.    )TupleListIterator)_iter_lines
_load_filec                   @   s   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZedee fddZededee fddZededee fddZededee fddZdS )CoNLLz
    A Conll class to easily load conll-u formats. This module can also load resources by iterating over string.
    This module is the main entrance to conll's functionalities.
    idtextlemmauposxposfeatsheaddepreldepsmisc#	_returnc                
   C   s,   t jt jt jt jt jt jt jt jt j	t j
g
S )zs
        Get the list of conll fields

        Returns:
            List[str]: Return list of conll fields
        )r   IDTEXTLEMMAUPOSXPOSFEATSHEADDEPRELDEPSMISC r    r    I/home/ubuntu/.local/lib/python3.10/site-packages/urduhack/conll/reader.py
get_fields   s   	zCoNLL.get_fields	file_namec                 C   s   t | S )a  
        Load a CoNLL-U file given its location.

        Args:
            file_name (str): The location of the file.
        Returns:
           List[Tuple]: A Conll object equivalent to the provided file.
        Raises:
            IOError: If there is an error opening the given filename.
            ValueError: If there is an error parsing the input into a Conll object.
        )r   )r#   r    r    r!   	load_file2   s   zCoNLL.load_filec                 c   sH    t | dd}t|D ]}|V  qW d   dS 1 sw   Y  dS )a  
        Iterate over a CoNLL-U file's sentences.

        Args:
            file_name (str): The name of the file whose sentences should be iterated over.
        Yields:
            Iterator[Tuple]: The sentences that make up the CoNLL-U file.
        Raises:
            IOError: If there is an error opening the file.
            ParseError: If there is an error parsing the input into a Conll object.
        utf8)encodingN)openr   )r#   filesentencer    r    r!   	iter_fileA   s   "zCoNLL.iter_filec                 c   s"    |   }t|D ]}|V  q	dS )a  
        Iterate over a CoNLL-U string's sentences.

        Use this method if you only need to iterate over the CoNLL-U file once and
        do not need to create or store the Conll object.

        Args:
            text (str): The CoNLL-U string.
        Yields:
            Iterator[Tuple]: The sentences that make up the CoNLL-U file.
        Raises:
            ParseError: If there is an error parsing the input into a Conll object.
        N)
splitlinesr   )r	   linesr)   r    r    r!   iter_stringR   s
   zCoNLL.iter_stringN)__name__
__module____qualname____doc__r   r   r   r   r   r   r   r   r   r   COMMENT_MARKERFIELD_DELIMITEREMPTYstaticmethodr   strr"   r   r$   r   r*   r-   r    r    r    r!   r   	   s.    r   N)	r1   typingr   r   r   urduhack.conll.parserr   r   r   r    r    r    r!   <module>   s   