o
    mi7                     @   s4   d Z ddlmZmZ G dd dZeddddZdS )	z2Provides the Separator tuple and its default value    )OptionalUnionc                   @   s   e Zd ZdZ			ddedee dee fddZdd
dZdd Ze	dd Z
e	dd Ze	dd ZdefddZdeeef deeef fddZdS )	Separatorz0Defines phone, syllable and word boundary tokens Nwordsyllablephonec                 C   s   t dd |||fD }tdd |||fD }t|t|kr)td||||r/t|nd| _|r8t|nd| _|rDt|| _d S d| _d S )Nc                 s       | ]}|r|V  qd S N .0sepr   r   N/home/kim/smarthome/.venv/lib/python3.10/site-packages/phonemizer/separator.py	<genexpr>       z%Separator.__init__.<locals>.<genexpr>c                 s   r	   r
   r   r   r   r   r   r      r   zcillegal separator with word="{}", syllable="{}" and phone="{}", must be all differents if not empty )	listsetlen
ValueErrorformatstr_phone	_syllable_word)selfr   r   r   Zsep1Zsep2r   r   r   __init__   s   
zSeparator.__init__otherc                 C   s$   | j |j ko| j|jko| j|jkS r
   r   r   r   )r   r   r   r   r   __eq__&   s
   

zSeparator.__eq__c                 C   s   d| j  d| j d| j dS )Nz	(phone: "z", syllable: "z
", word: "z")r   r   r   r   r   __str__,   s   
zSeparator.__str__c                 C      | j S )zPhones separator)r   r!   r   r   r   r   2      zSeparator.phonec                 C   r#   )zSyllables separator)r   r!   r   r   r   r   7   r$   zSeparator.syllablec                 C   r#   )zWords separator)r   r!   r   r   r   r   <   r$   zSeparator.wordvaluec                 C   s   || j | j| jhv S )z=Returns True if the separator has `value` as token separationr   )r   r%   r   r   r   __contains__A   s   zSeparator.__contains__field_separatorreturnc                 C   sh   |sdS t |tr|| v rtd| d|  |S |du r-d}|| v r+|d7 }|| v s#|S td| )a  Returns a suitable input/output separator based on token separator

        The input/output separator split orthographic and phonetic texts when
        using the --prepend-text option from command-line.

        Parameters
        ----------

        field_separator: bool or str
            If str, ensures it's value is not
            already defined as a token separator. If True choose one of "|",
            "||", "|||", "||||" (the first one that is not defined as a token
            separator)

        Returns
        -------
        The input/output separator, or False if ``field_separator`` is False

        Raises
        ------
        RuntimeError
            if ``field_separator`` is a str but is already registered as token separator

        Fzcannot prepend input with "z+" because it is already a token separator: T|z:invalid input/output separator, must be bool or str but is)
isinstancer   RuntimeError)r   r'   r   r   r   input_output_separatorE   s*   
z Separator.input_output_separator)r   NN)r   r   )__name__
__module____qualname____doc__r   r   r   r    r"   propertyr   r   r   r&   r   boolr,   r   r   r   r   r      s,    





r   r   r   r   N)r0   typingr   r   r   Zdefault_separatorr   r   r   r   <module>   s
   b