
    -iZ                         d Z ddlZej                            d           ddlmZ  G d d          Zedk    r ed           dd	d
dddddddddddddZ	dS dS )zK
stemmedAffix represents the data resulted from the morpholocigal analysis
    Nz../lib/c                   p   e Zd ZdZd=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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#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/ Z0d0 Z1d1 Z2d2 Z3d3 Z4d4 Z5d5 Z6d6 Z7d7 Z8d8 Z9d9 Z:d: Z;d; Z<d< Z=dS )>StemmedAffixzS
    stemmedAffix represents the data resulted from the morpholocigal analysis
    Nc                    d| _         d| _        d| _        d| _        d| _        d| _        d| _        d| _        |r	|                    dg           }|r4|d         | _         |d         | _        |d         | _        |d         | _        d	                    | j         | j        | j        | j        g          | _
        |                    d	d          | _        |                     |                    d
d                    | _        |                                 r.|                     |                    dd                    | _        |                                 | _        |                                 | _        |                                 | _        d| _        d| _        d| _        d| _        d| _        d| _        |                                 r3|                                 | _        |                                 | _        nF|                                 r2|                                 | _        |                                 | _        |                                 | _        |                                  | _!        | "                                | _        | #                                | _$        | %                                | _        d S )N r   Faffix         -tagstypetense)&	procleticprefixsuffixencletictag_type	tag_tenser   	tag_breakgetjoinr   _StemmedAffix__get_typeis_verb_StemmedAffix__get_tense_StemmedAffix__get_number
tag_number_StemmedAffix__get_inflecttag_inflect_StemmedAffix__get_gender
tag_gendertag3rdpersontag1stpersontag_defined
tag_tanwintag_jartag_istfham_StemmedAffix__is3rdperson_StemmedAffix__is1stpersonis_noun_StemmedAffix__is_defined_StemmedAffix__is_tanwin_StemmedAffix__has_jar_StemmedAffix__is_added	tag_added_StemmedAffix__is_break_StemmedAffix__is_3tftag_3tf_StemmedAffix__has_istfham)selfresult_dictaffs      R/var/www/html/speakWrite/venv/lib/python3.11/site-packages/qalsadi/stemmedaffix.py__init__zStemmedAffix.__init__   s]    	  	P//'2..C '!$Q!!f!!f #Adk4=I DJ $33DI OOKOOFB,G,GHHDM||~~ P!%!1!1+//'22N2N!O!O ++----//++-- "!  <<>> 	5 $ 2 2 4 4D $ 2 2 4 4D||~~ 5#'#4#4#6#6 "&"2"2"4"4~~''****}}--//    c                     | j         S )zu
        Get the type form of the input word
        @return: the given type.
        @rtype: unicode string
        r   r3   s    r6   get_typezStemmedAffix.get_type[        }r8   c                     | j         S )zh
        Get the procletic
        @return: the given procletic.
        @rtype: unicode string
        r   r;   s    r6   get_procleticzStemmedAffix.get_procletice   s     ~r8   c                     || _         dS )z
        Set the procletic
        @param newprocletic: the new given procletic.
        @type newprocletic: unicode string
        Nr?   )r3   newprocletics     r6   set_procleticzStemmedAffix.set_procletico   s     &r8   c                     | j         dk    S )zt
        return True if has procletic
        @return: True if procletic not empty.
        @rtype: Boolean
        r   r?   r;   s    r6   has_procleticzStemmedAffix.has_procleticw   s     ~##r8   c                     | j         S )zb
        Get the prefix
        @return: the given prefix.
        @rtype: unicode string
        r   r;   s    r6   
get_prefixzStemmedAffix.get_prefix        {r8   c                     || _         dS )zx
        Set the prefix
        @param newprefix: the new given prefix.
        @type newprefix: unicode string
        NrG   )r3   	newprefixs     r6   
set_prefixzStemmedAffix.set_prefix         r8   c                     | j         S )zb
        Get the suffix
        @return: the given suffix.
        @rtype: unicode string
        r   r;   s    r6   
get_suffixzStemmedAffix.get_suffix   rI   r8   c                     || _         dS )zy
        Set the suffix word
        @param newsuffix: the given suffix.
        @type newsuffix: unicode string
        NrO   )r3   	newsuffixs     r6   
set_suffixzStemmedAffix.set_suffix   rM   r8   c                     | j         S )zf
        Get the encletic
        @return: the given encletic.
        @rtype: unicode string
        r   r;   s    r6   get_encleticzStemmedAffix.get_encletic   r=   r8   c                     || _         dS )z|
        Set the encletic
        @param newencletic: the given encletic.
        @type newencletic: unicode string
        NrU   )r3   newencletics     r6   set_encleticzStemmedAffix.set_encletic   s     $r8   c                 L    | j         dk    p| j                            d          S )zr
        return True if has encletic
        @return: True if encletic not empty.
        @rtype: Boolean
        r   u   ل)r   r   
startswithr;   s    r6   has_encleticzStemmedAffix.has_encletic   s&     }"Bdk&<&<T&B&BBr8   c                 X   d| _         d|                                 v r| xj         dz  c_         nd|                                 v r| xj         dz  c_         ncd|                                 v r| xj         dz  c_         n<d|                                 v r&d|                                 vr| xj         dz  c_         d|                                 v r| xj         d	z  c_         nRd
|                                 v r<d|                                 vr&d|                                 vr| xj         d	z  c_         d|                                 v r| xj         dz  c_         d|                                 v r| xj         dz  c_         n&d|                                 v r| xj         dz  c_         | j         S )uz  
               Return int code of iflection state.
               the inflected cases are coded in binary like
               not defined        : 0  00000
               Invariable (mabni) : 1  00001
               marfou3            : 2  00010
               mansoub            : 4  00100
               majrour            : 8  01000
               majzoum            :16  10000
               mabni              :32 100000
               this codification allow to have two inflection for the same case,
               like feminin plural which ahve the same mark for Nasb and jar
               هذا الترمزي يسمح بتركيب حالتين إعرابيتين معا،
        مثل إعراب جمع المؤنث السالم بالكسرة في
               النصب والجر
               @return: inflection state numeric code
               @rtype: int
        r   u   الماضيr   u
   الأمر   مؤكدu   مبني
   مجهولu
   مرفوعr	   
   مضارعu
   منصوبu
   مجزوم   u
   مجرور      )r   get_tagsr;   s    r6   __get_inflectzStemmedAffix.__get_inflect   s   ,  T]]__,,!T]]__,,!4==??**!4==??**|4==??/R/R!4==??**!
 DMMOO++DMMOO33DMMOO33! 4==??**! 4==??**!T]]__,,"r8   c                    d| _         d|                                 v r| xj         dz  c_         d|                                 v r| xj         dz  c_         d|                                 v r\| xj         dz  c_         d|                                 v r| xj         d	z  c_         d
|                                 v r| xj         dz  c_         | j         S )uH  
        Return the int code of the number state.
        the number cases are coded in binary like
        not defined        : 0  00000
        single  : 1  00001
        dual    : 2  00010
        plural  : 4  00100
        masculin plural: 8  01000
        feminin plural : 16 10000
        this codification allow to have two marks for the same case,
        like irregular plural and single can have the same mark
        هذا الترميز يسمح بترميز المفرد وجمع التكسير معا
        @return: get the number state .
        @rtype: int
        r   u   مفردr   u   مثنىr	   u   جمعra   u   جمع مذكر سالمrb      جمع مؤنث سالمrc   )r   rd   r;   s    r6   __get_numberzStemmedAffix.__get_number   s    & ((OOq OO((OOq OOt}}&&OOq OO)T]]__<<1$)T]]__<<2% r8   c                     d| _         |sdS d|v r| xj         dz  c_         d|v r| xj         dz  c_         d|v r| xj         dz  c_         | j         S )u)  
        Return the numeric code of word type.
        the number cases are coded in binary like
        not defined        : 0  00000
        stopword  : 1  00001
        verb    : 2  00010
        noun  : 4  00100
        this codification allow to have two types for the same case,
        like a stop word can be a noun, the correspendant code is 101
        هذا الترميز يسمح بترميز الحروف والأسماء،
        بعض الأدوات هي أسماء
        @return: numeric code of type .
        @rtype: int
        r   STOPWORDr   Verbr	   Nounra   r:   )r3   
input_types     r6   
__get_typezStemmedAffix.__get_type  sq       	1##MMQMMZMMQMMZMMQMM}r8   c                     d| _         |sdS d|v rd| _         nd|v rd| _         nd|v rd| _         d|v r| xj         d	z  c_         d
|v r| xj         dz  c_         | j         S )aq  
        Return the numeric code of tense.
        the number cases are coded in binary like
        not defined        : 0  00000
        past        : 1  00001
        imperfect   : 2  00010    present and future
        imperative  : 4  00100
        passive     : 8  01000
        confirmed   : 16 10000
        this codification allow to have many tense attributes for the same case,
        like a imperfect passive and confirmed, the correspendant
        code is 11010 => 26
        @param input_tense : given tense
        @type input_tense: unicode
        @return: tense numeric code .
        @rtype: int
        r   u   ماضيr   r`   r	   u   أمرra   r_   rb   r^   rc   )r   )r3   input_tenses     r6   __get_tensezStemmedAffix.__get_tense9  s    &  	1$$DNN[((DNN$$DN;&&NNaNN$$NNb NN~r8   c                    d| _         d|                                 v r| xj         dz  c_         d|                                 v r| xj         dz  c_         n&d|                                 v r| xj         dz  c_         | j         S )aO  
        Return the int code of the gender state.
        the number cases are coded in binary like
        not defined        : 0  00000
        masculin  : 1  00001
        feminin    : 2  00010
        this codification allow to have case in the same word
        @return: get the numeric gender state .
        @rtype: int
        r   u   مذكرr   u   مؤنثr	   rg   )r    rd   r;   s    r6   __get_genderzStemmedAffix.__get_gender\  s~     ((OOq OO((OOq OOO'4==??::OOq OOr8   c                 Z    d|                                  v pd|                                  v S )
        Return True if the word has the state definde.
        @return: has the state defined.
        @rtype: True/False
        u
   تعريف   مضافrd   r;   s    r6   __is_definedzStemmedAffix.__is_definedt  s)     t}}.O*2OOr8   c                 Z    d|                                  v pd|                                  v S )
        Return True if the word has the 3rd person.
        @return: has the 3rd persontense.
        @rtype: True/False
           :هي:   :هو:rw   r;   s    r6   __is3rdpersonzStemmedAffix.__is3rdperson|  s)     4==??*Ih$--//.IIr8   c                 .    d|                                  v S )
        Return True if the word has the 1st person.
        @return: has the 1st persontense.
        @rtype: True/False
        u   :أنا:rw   r;   s    r6   __is1stpersonzStemmedAffix.__is1stperson  s     T]]__,,r8   c                 .    d|                                  v S )rz   r|   rw   r;   s    r6   is3rdperson_masculinz!StemmedAffix.is3rdperson_masculin       4==??**r8   c                 .    d|                                  v S )z
        Return True if the word has the 3rd person feminin.
        @return: has the 3rd person feminin.
        @rtype: True/False
        r{   rw   r;   s    r6   is3rdperson_femzStemmedAffix.is3rdperson_fem  r   r8   c                 .    d|                                  v S )m
        Return True if the word has tanwin.
        @return: has tanwin.
        @rtype: True/False
        u
   تنوينrw   r;   s    r6   __is_tanwinzStemmedAffix.__is_tanwin  s     t}}..r8   c                 .    d|                                  v S )zy
        Return True if the word has a jar factor attached.
        @return: has jar.
        @rtype: True/False
        u   جر:rw   r;   s    r6   	__has_jarzStemmedAffix.__has_jar  s     $--//))r8   c                 .    d|                                  v S )z}
        Return True if the word has a istfham factor attached.
        @return: has jar.
        @rtype: True/False
        u   استفهامrw   r;   s    r6   __has_istfhamzStemmedAffix.__has_istfham  s      4==??22r8   c                 6   |                                  r|                                 rdS d|                                 v s@t          j        |                                 v s t          j        |                                 v rdS |                                 rdS dS )zk
        Return True if the word has break.

        @return: is break.
        @rtype: True/False
        T   عطفF)rE   has_jarrd   arabyWAWr@   FEHr2   r;   s    r6   
__is_breakzStemmedAffix.__is_break  s      		DLLNN 		4''yD..0000yD..00004!! 	4ur8   c                 Z    d|                                  v pd|                                  v S )   
        Return True if the word has the state added مضاف.
        @return: has the state added.
        @rtype: True/False
        rv   u   اسم إضافةrw   r;   s    r6   
__is_addedzStemmedAffix.__is_added  s*     T]]__,V0Ct}}0VVr8   c                 .    d|                                  v S )m
        Return True if the word is a plural.
        @return: is plural.
        @rtype: True/False
        r   rw   r;   s    r6   __is_3tfzStemmedAffix.__is_3tf  r   r8   c                     | j         S )r   )r1   r;   s    r6   is_3tfzStemmedAffix.is_3tf       |r8   c                     | j         S )zu
        Get the tags form of the input word
        @return: the given tags.
        @rtype: unicode string
        r   r;   s    r6   rd   zStemmedAffix.get_tags  s     yr8   c                     || _         dS )zu
        Set the tags word
        @param newtags: the new given tags.
        @type newtags: unicode string
        Nr   )r3   newtagss     r6   set_tagszStemmedAffix.set_tags  s     			r8   c                 0    t          | j        dz            S )zp
        Return True if the word is a stop word.
        @return: is a noun.
        @rtype: True/False
        r	   boolr   r;   s    r6   is_stopwordzStemmedAffix.is_stopword  s     DMA%&&&r8   c                 6    t          | j        dz  dz            S )zk
        Return True if the word is a verb.
        @return: is a verb.
        @rtype: True/False
        r	   r   r;   s    r6   r   zStemmedAffix.is_verb       DMQ&*+++r8   c                 6    t          | j        dz  dz            S )zk
        Return True if the word is a noun.
        @return: is a noun.
        @rtype: True/False
        ra   r	   r   r;   s    r6   r)   zStemmedAffix.is_noun  r   r8   c                 0    t          | j        dz            S )u   
        Return True if the word has the state invariable (مبني).
        @return: has the state invariable.
        @rtype: True/False
        r	   r   r   r;   s    r6   is_invariablezStemmedAffix.is_invariable  s     D$q()))r8   c                 6    t          | j        dz  dz            S )z
        Return True if the word has the state marfou3.
        @return: has the state marfou3.
        @rtype: True/False
        r	   r   r;   s    r6   
is_marfou3zStemmedAffix.is_marfou3#       D$)A-...r8   c                 *    |                                  S )z
        Return True if the word has the state mabni.
        @return: has the state mabni.
        @rtype: True/False
        )r   r;   s    r6   is_mabnizStemmedAffix.is_mabni+  s     !!###r8   c                 ^    t          | j        dz  dz            p|                                 S )z
        Return True if the word has the state mansoub.
        @return: has the state mansoub.
        @rtype: True/False
        ra   r	   r   r   r   r;   s    r6   
is_mansoubzStemmedAffix.is_mansoub3  s0     D$)A-..F$2D2D2F2FFr8   c                 6    t          | j        dz  dz            S )
        Return True if the word has the state majrour.
        @return: has the state majrour.
        @rtype: True/False
        rb   r	   r   r;   s    r6   
is_majrourzStemmedAffix.is_majrour;  r   r8   c                 ^    t          | j        dz  dz            p|                                 S )r   rc   r	   r   r;   s    r6   
is_majzoumzStemmedAffix.is_majzoumC  s0     D$*Q.//G43E3E3G3GGr8   c                     | j         S )ru   )r#   r;   s    r6   
is_definedzStemmedAffix.is_definedK       r8   c                 0    t          | j        dz            S )z~
        Return True if the word has the tense past.
        @return: has the  tense past.
        @rtype: True/False
        r	   r   r   r;   s    r6   is_pastzStemmedAffix.is_pastS  s     DNQ&'''r8   c                 6    t          | j        dz  dz            S )z
        Return True if the word has the tense present.
        @return: has the  tense present.
        @rtype: True/False
        r	   r   r;   s    r6   
is_presentzStemmedAffix.is_present\       DNa'!+,,,r8   c                 6    t          | j        dz  dz            S )z
        Return True if the word has the tense passive.
        @return: has the  tense passive.
        @rtype: True/False
        rb   r	   r   r;   s    r6   
is_passivezStemmedAffix.is_passivee  r   r8   c                     | j         S )rz   )r!   r;   s    r6   is3rdpersonzStemmedAffix.is3rdpersonn         r8   c                     | j         S )r   )r"   r;   s    r6   is1stpersonzStemmedAffix.is1stpersonv  r   r8   c                     | j         S )r   )r.   r;   s    r6   is_addedzStemmedAffix.is_added~  s     ~r8   c                     | j         S r   )r$   r;   s    r6   	is_tanwinzStemmedAffix.is_tanwin  s     r8   c                     | j         S r   )r%   r;   s    r6   r   zStemmedAffix.has_jar  r   r8   c                     | j         S )zn
        Return True if the word has istfham.
        @return: has tanwin.
        @rtype: True/False
        )r&   r;   s    r6   has_istfhamzStemmedAffix.has_istfham  r   r8   c                     | j         S )zj
        Return True if the word has break.
        @return: is break.
        @rtype: True/False
        )r   r;   s    r6   is_breakzStemmedAffix.is_break  s     ~r8   c                 6    t          | j        dz  dz            S )zm
        Return True if the word is Feminin.
        @return: is Feminin.
        @rtype: True/False
        r	   )r   r    r;   s    r6   
is_femininzStemmedAffix.is_feminin       DOq(1,---r8   c                 6    t          | j        dz  dz            S )zi
        Return True if the word is  dual.
        @return: is  dual.
        @rtype: True/False
        r	   r   r   r;   s    r6   is_dualzStemmedAffix.is_dual  r   r8   c                 6    t          | j        dz  dz            S )r   ra   r	   r   r;   s    r6   	is_pluralzStemmedAffix.is_plural  r   r8   c                 6    t          | j        dz  dz            S )z~
        Return True if the word is  Masculin plural.
        @return: is masculin plural.
        @rtype: True/False
        rb   r	   r   r;   s    r6   is_masculin_pluralzStemmedAffix.is_masculin_plural  r   r8   c                 6    t          | j        dz  dz            S )z|
        Return True if the word is  Feminin plural.
        @return: is Feminin plural.
        @rtype: True/False
        rc   r	   r   r;   s    r6   is_feminin_pluralzStemmedAffix.is_feminin_plural  s     DOr)A-...r8   c                     | j         S )z%
        get attributes dict
        )__dict__r;   s    r6   get_dictzStemmedAffix.get_dict  s     }r8   c                     d}| j         }|                                D ]}|d|d||         dz  }|dz  }|                    d          S )zb
        Display objects result from analysis
        @return: text
        @rtype : text
        {z
		u'z'  =  u'z', z
		}utf8)r   keysencode)r3   textstmwordkeys       r6   __repr__zStemmedAffix.__repr__  sd     -<<>> 	D 	DCDgclllCCDD	{{6"""r8   )N)>__name__
__module____qualname____doc__r7   r<   r@   rC   rE   rH   rL   rP   rS   rV   rY   r\   r   r   r   r   r   r*   r'   r(   r   r   r+   r,   r2   r/   r-   r0   r   rd   r   r   r   r)   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r8   r6   r   r      s        80 80 80 80~    & & &$ $ $                $ $ $C C C9  9  9 v     D  6! ! !F  0P P PJ J J- - -+ + ++ + +/ / /* * *3 3 3  4W W W+ + +       ' ' ', , ,, , ,* * */ / /$ $ $G G G/ / /H H H     ( ( (- - -- - -! ! !! ! !           
 
 
. . .. . .. . .. . ./ / /  # # # # #r8   r   __main__testu   الحياةu   الْحَيَاةُu   الr   u   حياةu   ُu   تعريف::مرفوع*u   Noun:مصدرu   حَيَاةٌ)word	vocalizedr   r   stemr   r   r   freqroottemplater   originalsyntaxsemantic)
r   syspathappendpyarabic.arabyr   r   r   printRDICTr   r8   r6   <module>r     s     


 	         V# V# V# V# V# V# V# V#r z	E&MMM+)$! EEE r8   