HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/pyphen/__pycache__/__init__.cpython-310.pyc
o

we�&�	@s,dZddlZddlmZddlmZdZZdZiZ	e�
d�jZe�
d�j
Zd	ZiZze�d
�ZWneefyCee�jdZYnwee���D]!Zejdkrkejd
d�Zeee<e�d�dZeevrkeee<qJdd�eD�Zdd�ZGdd�d�Z Gdd�de!�Z"Gdd�d�Z#Gdd�d�Z$dS)zY

Pyphen
======

Pure Python module to hyphenate text, inspired by Ruby's Text::Hyphen.

�N)�	resources)�Pathz0.14.0)�Pyphen�	LANGUAGES�language_fallbackz\^{2}([0-9a-f]{2})z
(\d?)(\D?))�%�#�
LEFTHYPHENMIN�RIGHTHYPHENMIN�COMPOUNDLEFTHYPHENMIN�COMPOUNDRIGHTHYPHENMINzpyphen.dictionaries�dictionariesz.dic�����_cCsi|]}|��|�qS�)�lower)�.0�namerr�H/home/arjun/projects/env/lib/python3.10/site-packages/pyphen/__init__.py�
<dictcomp>-srcCsH|�dd����d�}|r"d�|�}|tvrt|S|��|s
dSdS)a	Get a fallback language available in our dictionaries.

    http://www.unicode.org/reports/tr35/#Locale_Inheritance

    We use the normal truncation inheritance. This function needs aliases
    including scripts for languages with multiple regions available.

    �-rN)�replacer�split�join�LANGUAGES_LOWERCASE�pop)�language�partsrrrr0s	
�rc@� eZdZdZdd�Zdd�ZdS)�AlternativeParserz�Parser of nonstandard hyphen pattern alternative.

    The instance returns a special int with data about the current position in
    the pattern when called with an odd value.

    cCsP|�d�}|d|_t|d�|_t|d�|_|�d�r&|jd7_dSdS)N�,r���.)r�change�int�index�cut�
startswith)�self�pattern�alternativerrr�__init__Hs


�zAlternativeParser.__init__cCs8|jd8_t|�}|d@rt||j|j|jf�S|S)Nr")r'r&�DataIntr%r()r*�valuerrr�__call__Ps
zAlternativeParser.__call__N)�__name__�
__module__�__qualname__�__doc__r-r0rrrrr Asr c@seZdZdZddd�ZdS)r.zE``int`` with some other data can be stuck to in a ``data`` attribute.NcCs0t�||�}|rt|t�r|j|_|S||_|S)z�Create a new ``DataInt``.

        Call with ``reference=dataint_object`` to use the data from another
        ``DataInt``.

        )r&�__new__�
isinstancer.�data)�clsr/r7�	reference�objrrrr5[s�zDataInt.__new__)NN)r1r2r3r4r5rrrrr.Ysr.c@r)�HyphDictzHyphenation patterns.c	sJi|_|�d�����}|��dkrd}|�|��d�dd�D]t}|��}|r-|�t	�r.q t
dd�|�}d	|vrKd
|vrK|�d	d�\}}t||��nt�t
�fdd�t|�D��\}}t|�d
krcq d
t|�}}||sv|d7}||rn||ds�|d8}||dr|||||�f|jd�|�<q i|_tdd�|jD��|_dS)zhRead a ``hyph_*.dic`` and parse its patterns.

        :param path: Path of hyph_*.dic to read

        �rbzmicrosoft-cp1251�cp1251�
r"NcSstt|�d�d��S)Nr"�)�chrr&�group)�matchrrr�<lambda>�sz#HyphDict.__init__.<locals>.<lambda>�/�=cs g|]\}}|�|pd�f�qS)�0r)r�i�string��factoryrr�
<listcomp>�s�z%HyphDict.__init__.<locals>.<listcomp>r�css�|]}t|�VqdS)N)�len)r�keyrrr�	<genexpr>�s�z$HyphDict.__init__.<locals>.<genexpr>)�patterns�open�readline�decoder�	read_textr�stripr)�ignored�	parse_hexr r&�zip�parse�maxrMr�cache�maxlen)	r*�path�encodingr+r,�tags�values�start�endrrIrr-ms<����zHyphDict.__init__cCs�|��}|j�|�}|durtd|�d�}dgt|�d}tt|�d�D]@}t||jt|��d}t|d|�D]*}|j�|||��}|sIq:|\}	}
t||	||	t|
��}t	t
|
||�||<q:q%dd�t|�D�|j|<}|S)a�Get a list of positions where the word can be hyphenated.

        :param word: unicode string of the word to hyphenate

        E.g. for the dutch word 'lettergrepen' this method returns ``[3, 6,
        9]``.

        Each position is a ``DataInt`` with a data attribute.

        If the data attribute is not ``None``, it contains a tuple with
        information about nonstandard hyphenation at that point: ``(change,
        index, cut)``.

        change
          a string like ``'ff=f'``, that describes how hyphenation should
          take place.

        index
          where to substitute the change, counting from the current point

        cut
          how many characters to remove while substituting the nonstandard
          hyphenation

        Nr$rr"cSs(g|]\}}|drt|d|d��qS)r#r")r9)r.)rrGr9rrrrK�s
��z&HyphDict.positions.<locals>.<listcomp>)rr[�getrM�range�minr\rP�slice�maprZ�	enumerate)r*�word�points�pointed_word�
referencesrG�stop�jr+�offsetr`�slice_rrr�	positions�s&��zHyphDict.positionsN)r1r2r3r4r-rqrrrrr;js0r;c@sBeZdZdZddd�Zdd�Zd	d
�Zddd
�Zddd�ZeZ	dS)rzEHyphenation class, with methods to hyphenate strings in various ways.Nr#TcCsB|stt|�}||_||_|r|tvrt|�t|<t||_dS)a�Create an hyphenation instance for given lang or filename.

        :param filename: filename of hyph_*.dic to read
        :param lang: lang of the included dict to use if no filename is given
        :param left: minimum number of characters of the first syllabe
        :param right: minimum number of characters of the last syllabe
        :param cache: if ``True``, use cached copy of the hyphenation patterns

        N)rr�left�right�hdcacher;�hd)r*�filename�langrrrsr[rrrr-�s
zPyphen.__init__cs*t|��j���fdd��j�|�D�S)z�Get a list of positions where the word can be hyphenated.

        :param word: unicode string of the word to hyphenate

        See also ``HyphDict.positions``. The points that are too far to the
        left or right are removed.

        cs*g|]}�j|kr�krnn|�qSr)rr)rrG�rsr*rrrK�s*z$Pyphen.positions.<locals>.<listcomp>)rMrsrurq)r*rirrxrrq�s	zPyphen.positionsccs��t|�|��D]?}|jr:|j\}}}||7}|��r|��}|�d�\}}|d|�|||||d�fVq|d|�||d�fVqdS)z�Iterate over all hyphenation possibilities, the longest first.

        :param word: unicode string of the word to hyphenate

        rEN)�reversedrqr7�isupper�upperr)r*ri�positionr%r'r(�c1�c2rrr�iterate�s�(�zPyphen.iteratercCs@|t|�8}|�|�D]\}}t|�|kr|||fSqdS)a�Get the longest possible first part and the last part of a word.

        :param word: unicode string of the word to hyphenate
        :param width: maximum length of the first part
        :param hyphen: unicode string used as hyphen character

        The first part has the hyphen already attached.

        Returns ``None`` if there is no hyphenation point before ``width``, or
        if the word could not be hyphenated.

        N)rMr)r*ri�width�hyphen�w1�w2rrr�wraps
��zPyphen.wrapcCsvt|�}t|�|��D]*}|jr/|j\}}}||7}|��r"|��}|�d|�||||�<q|�||�qd�|�S)a�Get the word as a string with all the possible hyphens inserted.

        :param word: unicode string of the word to hyphenate
        :param hyphen: unicode string used as hyphen character

        E.g. for the dutch word ``'lettergrepen'``, this method returns the
        unicode string ``'let-ter-gre-pen'``. The hyphen string to use can be
        given as the second parameter, that defaults to ``'-'``.

        rErL)	�listryrqr7rzr{r�insertr)r*rir��lettersr|r%r'r(rrr�inserteds
zPyphen.inserted)NNr#r#T)r)
r1r2r3r4r-rqrr�r�r0rrrrr�s


r)%r4�re�	importlibr�pathlibr�VERSION�__version__�__all__rt�compile�subrW�findallrYrVr�filesr
�AttributeError�	TypeError�__file__�parent�sorted�iterdirr]�suffixrr�
short_namerrr r&r.r;rrrrr�<module>s<	�
�c