
    -iL                         d Z ddlmZ ddlmZmZmZmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZ ddlmZ ddlmZ ddlmZ  G d dej                  ZdS )z
Noun Class for derivation
@author: Taha Zerrouki
@contact: taha dot zerrouki at gmail dot com
@copyright: Arabtechies, Arabeyes, Taha Zerrouki
@license: GPL
@date:2016/04/01
@version: 0.1
    N)FATHADAMMAKASRASHADDASUKUNHAMZAALEFNOON	YEH_HAMZAWAWTATWEELMEEMr   YEHTEHALEF_MAKSURADAMMATANc                   4    e Zd ZdZefdZd Zd Zd Zd Z	dS )	NounClasszD
    Noun Class: represent a derived noun from a verb or a root
    c                     t           j                            | |d|           |                                  |                                  dS )a   
        init method
        @param verb: the given verb
        @type verb: unicode.
        @param transitive: the verb is transitive or not
        @type transitive: Boolean.        
        @param future_type: The mark of the third radical letter in the verb, 
        used for triletiral verb only. Default value is Fatha; 
        @type future_type: unicode; one arabic letter (Fatha, Damma, Kasra).        
        TN)	classverb	VerbClass__init___prepare_subject_stem_prepare_object_stem)selfverb
transitivefuture_types       Q/var/www/html/speakWrite/venv/lib/python3.11/site-packages/libqutrub/classnoun.pyr   zNounClass.__init__-   sK     	$$T4{CCC""$$$!!#####    c                     | j         }| j        }|}|}| j        dk    rt          |          dk    r|d         t          z   |d         z   }nR|                    t                    s|                    t          j                  r|d         |d         z   t          z   }t          j
        t          z   t          z   }n| j        dk    rB|                    t                    r(t          t          z   t           z   t          z   t          z   }n8| j        t          j                 j        }| j        t          j                 j        }t          |          t          |          k     r|                     ||          }| j        dk    r\| j        dk    r%|                    t                    rt          |z   }n,|                    t                    rt          |dd         z   }t-          j        t          j        ||          | j        t          j        <   dS )u#  
        Prepare the derivation stems 
         Those stems will be concatenated with conjugation affixes.
          This function store results in self.tab_conjug_stem. 
          This function prepare conjugation stems for the following nouns type:
          - اسم الفاعل
              r         N)word_letters
word_marksvlengthlenr   endswithr   vconstALEF_MAMDUDAr   ALEF_HARAKAr   r   
startswithr   r   r   tab_conjug_stemTenseFuturemarksletters_homogenize_harakatr   
ConjugStemSubjectNoun)r   r2   r1   derivation_subject_marksderivation_subject_letterss        r   r   zNounClass._prepare_subject_stemF   s   F ##( %,"<1 7||q  -4QZ%-?'!*-L**!!,// K73C3CFDW3X3X K-4QZ'!*-Ds-J*
 (.'9E'AE'I$$ |q  W%7%7%<%<  ,15=5+@5+H5+P(( ,0+?@R+S+Y( .2-A&BT-U-]* u::45555'+'?'?G_'`'`$<1|q  W%7%7%<%< +03K+K(( ,66u== S.36Nqrr6R.R+3<3G68P4R 4RV/000r    c                    | j         }| j        }|}|}| j        dk    r>t          |          dk    r:| j        t
          j                 j        }| j        t
          j                 j        }n)| j         	                    t                    s>| j         	                    t                    s| j         	                    t                    r9| j        t
          j                 j        }| j        t
          j                 j        }n| j         	                    t                    r|d         |d         dz  z   }n|}t          t          z   t
          j        z   t"          z   }n8| j        t
          j                 j        }| j        t
          j                 j        }t'          j        t
          j        ||          | j        t
          j        <   dS )u0  
        Prepare the derivation stems 
         Those stems will be concatenated with conjugation affixes.
          This function store results in self.tab_conjug_stem. 
          This function prepare conjugation stems for the following nouns type:
          - اسم المفعول
          
        r"   r#   r   r$   N)r&   r'   r(   r)   r/   r+   r0   r1   r2   r*   r   r	   r   r   r   r   
WAW_HARAKAr   TensePassiveFuturer   r4   
ObjectNoun)r   r2   r1   derivation_object_marksderivation_object_letterss        r   r   zNounClass._prepare_object_stem   s    #"'$+!L <1 7||q   +/*>v?Q*R*X',0,@AS,T,\))#,,\:: U''--U151B1K1KC1P1PU
 +/*>v?Q*R*X',0,@AS,T,\))$--f55 918WQZ\1I--18-+05=6;L+Lu+T'' '+&:6;T&U&[#(,(<V=V(W(_% 3<2F46M3O 3OV.///r    c                    |t           j        k    r| j        dk    rd}nt          }t          }n#|t           j        k    rt          }t          }nd}d}| j        |         j        }| j        |         j        }|dk    r|}|d         }|dd         }nd}d}t          |z   }| j
        d                             |          r| j
        d         |         \  }}	n)t          j        |          \  }}	||	f| j
        d         |<   ||z   |z   }
||dd         z   |	z   }||z   |dd         z   }
d                    |
|g          }| j
        d	                             |          r| j
        d	         |         }n%t          j        |
|          }|| j
        d	         |<   d                    |
|g          }| j
        d
                             |          r| j
        d
         |         }n%t          j        |
|          }|| j
        d
         |<   |S )a/  
        Conjugate a verb in a given tense with a pronoun.
        @param tense: given tense
        @type tense: unicode name of the tense
        @param pronoun: given pronoun
        @type pronoun: unicode name of the pronoun
        @return: conjugated verb
        @rtype: unicode;        
        r"    r   r$   Nsuffix-sukunstandard)r+   r5   r(   r   r   r;   r/   r2   r1   r   cache_standardhas_keyar_verbuniformate_suffixjointreat_sukun2	standard2)r   	noun_typepre_valsuf_valstem_lstem_m	pre_val_l	pre_val_m	suf_val_l	suf_val_mconj_lconj_m	key_cacheconjs                 r   conjugate_nounzNounClass.conjugate_noun	  s<    ***|q  GG&+++GGG GG%i08%i06 c>>Iq	IABBZFFII G# x(00':: 	L%)%8%B7%K"Y		%,%>w%G%G"Y	6?5KD)'2V#i/VCRC[(94V#im3 IIvv.//	w'//	:: 	=(1)<FF )&&99F6<D(3 IIvv.//	z*229== 	>&z29=DD$VV44D9=D
+I6r    c                    |                      t          j                  }|                      t          j                  }|                    t
          j                  r|dd         t
          j        z   }| j        dk    r1|                    t
          j	                  r|t          t          z   z  }| j        dk    r?|                    t          dz  t          z             r|dd         t          z   t          z   }|                    t
          j                  r|dd         t
          j        z   }d                    ||g          S )a-  
        Derivate a subject and object nouns from a verb
        @param tense: given tense
        @type tense: unicode name of the tense
        @param pronoun: given pronoun
        @type pronoun: unicode name of the pronoun
        @return: conjugated verb
        @rtype: unicode;        
        NrA   r"   r#   	)rY   r+   r5   r;   r*   arabyr   r   r(   r   r   r   rI   )r   subjobjs      r   derivatezNounClass.derivateW  s    ""6#566""6#455==%% 	,9U^+D<1ei!8!8&8##C <1#,,s1uU{";";crc(F"X-C<<$$ 	*crc(5>)Czz4*%%%r    N)
__name__
__module____qualname____doc__r   r   r   r   rY   r`    r    r   r   r   )   s          6; $ $ $ $2cR cR cRJ\O \O \O|L L L\& & & & &r    r   )rd   pyarabic.arabyr]   r   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   libqutrub.classverbr   libqutrub.verb_const
verb_constr+   libqutrub.ar_verbrG   r   r   re   r    r   <module>rk      s~  .       N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N ' ' ' ' ' ' & & & & & & # # # # # #G& G& G& G& G&	# G& G& G& G& G&r    