Ë
    çÍ:je1  ã                   ó2   — d Z ddlZddlmZ  G d„ de«      Zy)aÐ  
ARLSTem Arabic Stemmer
The details about the implementation of this algorithm are described in:
K. Abainia, S. Ouamour and H. Sayoud, A Novel Robust Arabic Light Stemmer ,
Journal of Experimental & Theoretical Artificial Intelligence (JETAI'17),
Vol. 29, No. 3, 2017, pp. 557-573.
The ARLSTem is a light Arabic stemmer that is based on removing the affixes
from the word (i.e. prefixes, suffixes and infixes). It was evaluated and
compared to several other stemmers using Paice's parameters (under-stemming
index, over-stemming index and stemming weight), and the results showed that
ARLSTem is promising and producing high performances. This stemmer is not
based on any dictionary and can be used on-line effectively.
é    N)ÚStemmerIc                   ód   — 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d„ Zy)ÚARLSTemaY  
    ARLSTem stemmer : a light Arabic Stemming algorithm without any dictionary.
    Department of Telecommunication & Information Processing. USTHB University,
    Algiers, Algeria.
    ARLSTem.stem(token) returns the Arabic stem for the input token.
    The ARLSTem Stemmer requires that all tokens are encoded using Unicode
    encoding.
    c                 óÒ  — t        j                  d«      | _        t        j                  d«      | _        t        j                  d«      | _        g d¢| _        g d¢| _        ddg| _        g d¢| _        d	d
g| _	        ddg| _
        ddg| _        ddg| _        g d¢| _        ddg| _        ddg| _        ddg| _        ddg| _        g d¢| _        ddg| _        g d¢| _        g d¢| _        y )Nz[\u0622\u0623\u0625]z[\u0649]z[\u064B-\u065F])u   Ø§Ù„u   Ù„Ù„u   Ù�Ù„u   Ù�Ø¨)u   Ø¨Ø§Ù„u   ÙƒØ§Ù„u   ÙˆØ§Ù„u   Ù�Ù„Ù„u   ÙˆÙ„Ù„)u   Ù�Ø¨Ø§Ù„u   ÙˆØ¨Ø§Ù„u   Ù�ÙƒØ§Ù„u   ÙƒÙŠu   ÙƒÙ…u   Ù‡Ø§u   Ù‡Ù…u   ÙƒÙ…Ø§u   ÙƒÙ†Ù‘u   Ù‡Ù…Ø§u   Ù‡Ù†Ù‘)õ   Ø§Ù†u   ÙŠÙ†õ   ÙˆÙ†u   ØªØ§Ù†u   ØªÙŠÙ†r   r   u   Ø³Øªu   Ø³ÙŠu   Ø³Ø§u   Ø³Ù†)u   Ù„Ù†u   Ù„Øªu   Ù„ÙŠu   Ù„Ø£u   ØªÙ…Ø§u   ØªÙ†Ù‘)õ   Ù†Ø§u   ØªÙ…u   ØªØ§õ   ÙˆØ§)õ   Øªõ   Ø§õ   Ù†)ÚreÚcompileÚre_hamzated_alifÚre_alifMaqsuraÚre_diacriticsÚpr2Úpr3Úpr32Úpr4Úsu2Úsu22Úsu3Úsu32Úpl_si2Úpl_si3Úverb_su2Úverb_pr2Ú	verb_pr22Ú	verb_pr33Ú	verb_suf3Ú	verb_suf2Ú	verb_suf1)Úselfs    úf/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/nltk/stem/arlstem.pyÚ__init__zARLSTem.__init__*   sù   € ä "§
¡
Ð+BÓ CˆÔÜ Ÿj™j¨Ó5ˆÔÜŸZ™ZÐ(:Ó;ˆÔò TˆŒâUˆŒà)Ð+?Ð@ˆŒ	ò
ˆŒð # NÐ3ˆŒà# ^Ð4ˆŒ	à(Ð*>Ð?ˆŒà)Ð+?Ð@ˆŒ	ò GˆŒà+Ð-AÐBˆŒð (¨Ð8ˆŒà'¨Ð8ˆŒà(¨.Ð9ˆŒò
ˆŒð /Ð0DÐEˆŒò
ˆŒò 8ˆ�ó    c                 óL  — 	 |€t        d«      ‚| j                  |«      }| j                  |«      }|�|}| j                  |«      }| j	                  |«      }|€*| j                  |«      }|�|S |€| j                  |«      S |S |S # t         $ r}t        |«       Y d}~yd}~ww xY w)zN
        call this function to get the word's stem based on ARLSTem .
        NzUThe word could not be stemmed, because                                  it is empty !)Ú
ValueErrorÚnormÚprefÚsuffÚ	plur2singÚfem2mascÚverbÚprint)r$   ÚtokenÚpreÚpsÚfmÚes         r%   ÚstemzARLSTem.stemd   sº   € ð	Øˆ}Ü ð0óð ð
 —I‘I˜eÓ$ˆEà—)‘)˜EÓ"ˆCØˆØ�à—I‘I˜eÓ$ˆEà—‘ Ó&ˆBØˆzà—]‘] 5Ó)�Ø�>Ø�Ià�{à#Ÿy™y¨Ó/Ð/ð ˆLð �	øäò 	Ü�!�H‰Hûð	ús*   ‚A+B Á.B ÂB ÂB Â	B#ÂBÂB#c                 óö   — | j                   j                  d|«      }| j                  j                  d|«      }| j                  j                  d|«      }|j	                  d«      rt        |«      dkD  r|dd }|S )z±
        normalize the word by removing diacritics, replacing hamzated Alif
        with Alif replacing AlifMaqsura with Yaa and removing Waaw at the
        beginning.
        Ú r   õ   ÙŠu   Ùˆé   é   N)r   Úsubr   r   Ú
startswithÚlen©r$   r1   s     r%   r*   zARLSTem.norm‡   sv   € ð ×"Ñ"×&Ñ& r¨5Ó1ˆà×%Ñ%×)Ñ)¨(°EÓ:ˆà×#Ñ#×'Ñ'¨°%Ó8ˆð ×Ñ˜HÔ%¬#¨e«*°qª.Ø˜!˜"�IˆEØˆr'   c                 ó¾  — t        |«      dkD  r)| j                  D ]  }|j                  |«      sŒ|dd c S  t        |«      dkD  r)| j                  D ]  }|j                  |«      sŒ|dd c S  t        |«      dkD  r)| j                  D ]  }|j                  |«      sŒ|dd c S  t        |«      dkD  r*| j
                  D ]  }|j                  |«      sŒ|dd c S  yy)z<
        remove prefixes from the words' beginning.
        é   r:   Né   é   é   )r>   r   r=   r   r   r   )r$   r1   Úp3Úp4Úp2s        r%   r+   zARLSTem.pref™   sï   € ô ˆu‹:˜Š>Ø—h‘hò %�Ø×#Ñ# BÕ'Ø   ˜9Ò$ð%ô ˆu‹:˜Š>Ø—h‘hò %�Ø×#Ñ# BÕ'Ø   ˜9Ò$ð%ô ˆu‹:˜Š>Ø—i‘iò %�Ø×#Ñ# BÕ'Ø   ˜9Ò$ð%ô ˆu‹:˜Š>Ø—h‘hò %�Ø×#Ñ# BÕ'Ø   ˜9Ò$ñ%ð r'   c                 óš  — |j                  d«      rt        |«      dkD  r|dd S t        |«      dkD  r)| j                  D ]  }|j                  |«      sŒ|dd c S  t        |«      dkD  r)| j                  D ]  }|j                  |«      sŒ|dd c S  |j                  d	«      rt        |«      dkD  r|dd }|S t        |«      dkD  r)| j                  D ]  }|j                  |«      sŒ|dd c S  t        |«      dkD  r)| j
                  D ]  }|j                  |«      sŒ|dd c S  |j                  d
«      rt        |«      dkD  r|dd S |S )z6
        remove suffixes from the word's end.
        u   Ùƒr:   NéÿÿÿÿrC   éþÿÿÿrA   éýÿÿÿu   Ù‡r	   )Úendswithr>   r   r   r   r   )r$   r1   Ús2Ús3s       r%   r,   zARLSTem.suff®   sS  € ð �>‰>˜(Ô#¬¨E«
°QªØ˜˜"�:ÐÜˆu‹:˜Š>Ø—h‘hò &�Ø—>‘> "Õ%Ø   "˜:Ò%ð&ô ˆu‹:˜Š>Ø—h‘hò &�Ø—>‘> "Õ%Ø   "˜:Ò%ð&ð �>‰>˜(Ô#¬¨E«
°QªØ˜#˜2�JˆEØˆLÜˆu‹:˜Š>Ø—i‘iò &�Ø—>‘> "Õ%Ø   "˜:Ò%ð&ô ˆu‹:˜Š>Ø—i‘iò &�Ø—>‘> "Õ%Ø   "˜:Ò%ð&ð �>‰>˜.Ô)¬c°%«j¸1ªnØ˜˜"�:ÐØˆr'   c                 óN   — |j                  d«      rt        |«      dkD  r|dd S yy)zR
        transform the word from the feminine form to the masculine form.
        u   Ø©r:   NrI   )rL   r>   r?   s     r%   r.   zARLSTem.fem2mascË   s.   € ð �>‰>˜(Ô#¬¨E«
°QªØ˜˜"�:Ðð )7Ð#r'   c                 óô  — t        |«      dkD  r)| j                  D ]  }|j                  |«      sŒ|dd c S  t        |«      dkD  r)| j                  D ]  }|j                  |«      sŒ|dd c S  t        |«      dkD  r|j                  d«      r|dd S t        |«      dkD  r$|j	                  d«      r|d	   dk(  r|dd	 |dd z   S t        |«      dkD  r&|j	                  d«      r|d   dk(  r|d
d |d   z   S yyy)zO
        transform the word from the plural form to the singular form.
        rC   NrJ   rA   rK   r:   u   Ø§Øªr   rD   r;   rI   )r>   r   rL   r   r=   )r$   r1   Úps2Úps3s       r%   r-   zARLSTem.plur2singÒ   s  € ô ˆu‹:˜Š>Ø—{‘{ò &�Ø—>‘> #Õ&Ø   "˜:Ò%ð&ô ˆu‹:˜Š>Ø—{‘{ò &�Ø—>‘> #Õ&Ø   "˜:Ò%ð&ô ˆu‹:˜Š>˜eŸn™n¨^Ô<Ø˜˜"�:ÐÜˆu‹:˜Š>˜e×.Ñ.¨xÔ8¸UÀ1¹XÈÒ=QØ˜˜!�9˜u Q R˜yÑ(Ð(Üˆu‹:˜Š>˜e×.Ñ.¨xÔ8¸UÀ2¹YÈ(Ò=RØ˜˜2�;  r¡Ñ*Ð*ð >SÐ8ˆ>r'   c                 óö   — | j                  |«      }|�|S | j                  |«      }|�|S | j                  |«      }|�|S | j                  |«      }|�|S | j	                  |«      }|�|S | j                  |«      S )z=
        stem the verb prefixes and suffixes or both
        )Úverb_t1Úverb_t2Úverb_t3Úverb_t4Úverb_t5Úverb_t6)r$   r1   Úvbs      r%   r/   zARLSTem.verbå   s‹   € ð �\‰\˜%Ó ˆØˆ>ØˆIØ�\‰\˜%Ó ˆØˆ>ØˆIØ�\‰\˜%Ó ˆØˆ>ØˆIØ�\‰\˜%Ó ˆØˆ>ØˆIØ�\‰\˜%Ó ˆØˆ>ØˆIØ�|‰|˜EÓ"Ð"r'   c                 ó  — t        |«      dkD  r:|j                  d«      r)| j                  D ]  }|j                  |«      sŒ|dd c S  t        |«      dkD  r:|j                  d«      r)| j                  D ]  }|j                  |«      sŒ|dd c S  t        |«      dkD  rw|j                  d«      rft        |«      dkD  r|j                  d«      r|dd S |j                  d«      r|dd	 S |j                  d«      r|dd	 S |j                  d
«      r|dd	 S t        |«      dkD  r'|j                  d«      r|j                  d
«      r|dd	 S t        |«      dkD  r)|j                  d«      r|j                  d
«      r|dd	 S yyy)z8
        stem the present prefixes and suffixes
        rA   r   r;   rJ   r9   rC   r   r
   rI   r   N)r>   r=   r   rL   r   ©r$   r1   rM   s      r%   rT   zARLSTem.verb_t1ú   sy  € ô ˆu‹:˜Š>˜e×.Ñ.¨xÔ8Ø—k‘kò '�Ø—>‘> "Õ%Ø   2˜;Ò&ð'ô ˆu‹:˜Š>˜e×.Ñ.¨xÔ8Ø—m‘mò '�Ø—>‘> "Õ%Ø   2˜;Ò&ð'ô ˆu‹:˜Š>˜e×.Ñ.¨xÔ8ä�5‹z˜AŠ~ %§.¡.°Ô"@Ø˜Q˜r�{Ð"à�~‰~˜hÔ'Ø˜Q˜r�{Ð"à�~‰~˜hÔ'Ø˜Q˜r�{Ð"à�~‰~˜hÔ'Ø˜Q˜r�{Ð"äˆu‹:˜Š>˜e×.Ñ.¨xÔ8¸U¿^¹^ÈHÔ=UØ˜˜2�;Ðäˆu‹:˜Š>˜e×.Ñ.¨xÔ8¸U¿^¹^ÈHÔ=UØ˜˜2�;Ðð >VÐ8ˆ>r'   c                 óÀ  — t        |«      dkD  rÊ| j                  D ]9  }|j                  | j                  d   «      sŒ"|j	                  |«      sŒ4|dd c S  |j                  | j                  d   «      r#|j	                  | j                  d   «      r|dd S |j                  | j                  d   «      r#|j	                  | j                  d   «      r|dd S t        |«      dkD  r4|j                  | j                  d   «      r|j	                  d«      r|dd S t        |«      dkD  r6|j                  | j                  d   «      r|j	                  d«      r|dd S y	y	y	)
z7
        stem the future prefixes and suffixes
        rB   r   rD   rJ   r;   rA   r   rI   N)r>   r   r=   r   rL   r\   s      r%   rU   zARLSTem.verb_t2  sG  € ô ˆu‹:˜Š>Ø—k‘kò '�à×#Ñ# D§M¡M°!Ñ$4Õ5¸%¿.¹.ÈÕ:LØ   2˜;Ò&ð'ð
 ×Ñ §¡¨aÑ 0Ô1°e·n±nÀTÇ[Á[ÐQRÁ^Ô6TØ˜Q˜r�{Ð"à×Ñ §¡¨aÑ 0Ô1°e·n±nÀTÇ[Á[ÐQRÁ^Ô6TØ˜Q˜r�{Ð"ô �‹J˜ŠNØ× Ñ  §¡¨qÑ!1Ô2Ø—‘˜xÔ(à˜˜2�;Ðô �‹J˜ŠNØ× Ñ  §¡¨qÑ!1Ô2Ø—‘˜xÔ(à˜˜2�;Ðð )ð 3ð r'   c                 óP  — t        |«      dkD  r)| j                  D ]  }|j                  |«      sŒ|dd c S  t        |«      dkD  r)| j                  D ]  }|j                  |«      sŒ|dd c S  t        |«      dkD  r*| j                  D ]  }|j                  |«      sŒ|dd c S  yy)z+
        stem the present suffixes
        rA   NrK   rC   rJ   r:   rI   )r>   r!   rL   r"   r#   )r$   r1   r   r   Úsu1s        r%   rV   zARLSTem.verb_t38  s¯   € ô ˆu‹:˜Š>Ø—~‘~ò &�Ø—>‘> #Õ&Ø   "˜:Ò%ð&ô ˆu‹:˜Š>Ø—~‘~ò &�Ø—>‘> #Õ&Ø   "˜:Ò%ð&ô ˆu‹:˜Š>Ø—~‘~ò &�Ø—>‘> #Õ&Ø   "˜:Ò%ñ&ð r'   c                 ó    — t        |«      dkD  r@| j                  D ]  }|j                  |«      sŒ|dd c S  |j                  d«      r|dd S yy)z+
        stem the present prefixes
        r:   r;   Nr9   )r>   r#   r=   )r$   r1   Úpr1s      r%   rW   zARLSTem.verb_t4I  sb   € ô ˆu‹:˜Š>Ø—~‘~ò %�Ø×#Ñ# CÕ(Ø   ˜9Ò$ð%ð ×Ñ Ô)Ø˜Q˜R�yÐ ð *ð	 r'   c                 óÆ   — t        |«      dkD  rR| j                  D ]  }|j                  |«      sŒ|dd c S  | j                  D ]  }|j                  |«      sŒ|dd c S  |S )z*
        stem the future prefixes
        rC   rD   N)r>   r   r=   r   )r$   r1   r   s      r%   rX   zARLSTem.verb_t5T  sr   € ô ˆu‹:˜Š>Ø—~‘~ò %�Ø×#Ñ# CÕ(Ø   ˜9Ò$ð%ð —}‘}ò %�Ø×#Ñ# CÕ(Ø   ˜9Ò$ð%ð ˆr'   c                 ót   — t        |«      dkD  r)| j                  D ]  }|j                  |«      sŒ|dd c S  |S )z)
        stem the order prefixes
        rC   rD   N)r>   r    r=   )r$   r1   r   s      r%   rY   zARLSTem.verb_t6a  sC   € ô ˆu‹:˜Š>Ø—~‘~ò %�Ø×#Ñ# CÕ(Ø   ˜9Ò$ð%ð ˆr'   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r&   r6   r*   r+   r,   r.   r-   r/   rT   rU   rV   rW   rX   rY   © r'   r%   r   r       sP   „ ñò88òt!òFò$%ò*ò:ò+ò&#ò*ò@ò<&ò"	!òór'   r   )rg   r   Únltk.stem.apir   r   rh   r'   r%   ú<module>rj      s    ðñó 
å "ôIˆhõ Ir'   