
    -iQ                        d Z ddlmZ ddlmZ dddddddddddddddZi ej        dej        dej	        dej
        dej        d	ej        d
ej        dej        dej        dej        dej        dej        dej        dej        dej        dej        dej        dej        dej        dej        dej        dej        dej        dej        dej        dej         di	Z! G d d           Z"dS )!zC
The conjugation display class to manage different display format.
    N )u   أناu   أنتu   أنتِu   هوu   هيu
   أنتماu   أنتما مؤu   هماu   هما مؤu   نحنu   أنتمu   أنتنu   همu   هن123u   4ِ567891011121314202122232425262728293031c                       e Zd ZdZi Zi ZdZdZdZi Z	dZ
d Zd Zd Zd Zd	 Zd
 Zd Zd Zd Zd Zd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S )ConjugateDisplayze
    conjugatedisplay class is used to display verb conjugation 
    in different ways and uses.
    r   TextFc                 j   t           j        t                                          t           j        t                                          t           j        t                                          t           j        t                                          t           j        t                                          t           j        t                                          t           j	        t                                          t           j
        t                                          t           j        t                                          t           j        t                                          t           j        t                                          i| _        || _        i | _        d| _        d| _        d| _        d| _        dS )z
        Create the conjugedtdisplay instance for the verb.
        @param verb: given verb.
        @type verb unicode.
        r   r   F0N)vconst	TensePastONE_TENSE_PRONOUNcopyTensePassivePastTenseFutureTensePassiveFutureTenseJussiveFutureTensePassiveJussiveFutureTenseSubjunctiveFutureTensePassiveSubjunctiveFutureTenseImperativeTenseConfirmedFutureTenseConfirmedImperative
tab_conjugverbtextmodefuture_form
transitivebab)selfr1   s     X/var/www/html/speakWrite/venv/lib/python3.11/site-packages/libqutrub/conjugatedisplay.py__init__zConjugateDisplay.__init__V   s%    &++--
-2244
(--//
/4466
/4466
$%6%;%;%=%=
!"3"8"8":":
():)?)?)A)A
,1133
 1 6 6 8 8
#$5$:$:$<$< 			    c                 h    i | _         d| _        i | _        d| _        d| _        d| _        d| _        d S )Nr   r   Fr!   )r0   r1   r2   r3   r4   r5   r6   r7   s    r8   __del__zConjugateDisplay.__del__p   s8    			r:   c                     || _         dS )ag   
        Set the display mode as:
            - 'Text':
            - 'HTML':
            - 'HTMLColoredDiacritics':
            - 'DICT':
            - 'CSV':
            - 'GUI':
            - 'TABLE':
            - 'XML':
            - 'TeX':
            - 'ROWS':
        @param mode: the given mode to display result
        @type mode: unicode
        N)r3   )r7   r3   s     r8   setmodezConjugateDisplay.setmode{   s      			r:   c                     d| _         dS )z6 
        Set the transitivity value to True.
        TN)r5   r<   s    r8   settransitivezConjugateDisplay.settransitive   s     r:   c                     || _         dS )zy 
        Set the bab sarf value to bab
        @param bab: the given sarf bab.
        @type bab: integer (1-6)
        N)r6   )r7   r6   s     r8   setbabzConjugateDisplay.setbab   s     r:   c                     || _         dS )u    
        Set the future form of the verb value to future_form.
        مثلا: صرب يصرب
        @param future_form: the future form.
        @type future_form: unicode
        N)r4   )r7   r4   s     r8   set_future_formz ConjugateDisplay.set_future_form   s     'r:   c                     | j         S )ze
        Get attributes as text
        @return: Attributes as text.
        @rtype: unicode
        r2   r<   s    r8   get_verb_attributsz#ConjugateDisplay.get_verb_attributs   s     yr:   c                 *    |dk    r|| j         |<   dS dS )a  
        Add a new attribut to display, like the transitivity 
        the root and the future form.
        @param title: the title of the attribute to display.
        @type title: unicode
        @param value:the value if the attribute.
        @type value: unicode
        r   NrG   )r7   titlevalues      r8   add_attributzConjugateDisplay.add_attribut   s&     B;;$DIe ;r:   c                 \    || j         v r"|| j         |         v r| j         |         |         S dS )aB  
        Get the conjugated verb by tense and pronoun.
        @param tense: tense of the added conjuagtion.
        @type tense: unicode
        @param pronoun: pronoun of the added conjuagtion.
        @type pronoun: unicode
        @return : conjugated form of verb if exists.
        @rtype : unicode
        
        r   r0   )r7   tensepronouns      r8   get_conjzConjugateDisplay.get_conj   s:     T_$$$/%000u-g66sr:   c                 L    || j         vr
i | j         |<   || j         |         |<   dS )a=  
        Add a new conjugation to display.
        @param tense: tense of the added conjuagtion.
        @type tense: unicode
        @param pronoun: pronoun of the added conjuagtion.
        @type pronoun: unicode
        @param verbconjugated:aded conjuagtion.
        @type verbconjugated:unicode
        
        NrN   )r7   rO   rP   verbconjugateds       r8   addzConjugateDisplay.add   s4     $/))%'DOE"*8w'''r:   Nc                 8    |                      | j        |          S )a[  
        Display The conjugation result for a list of tenses, 
        with a display mode given by the class attribute.
        Set the display mode as:
            - 'Text':
            - 'HTML':
            - 'HTMLColoredDiacritics':
            - 'DICT':
            - 'CSV':
            - 'GUI':
            - 'TABLE':
            - 'XML':
            - 'TeX':
            - 'ROWS':
        @param listtense: the given tenses list to display result
        @type listtense: list of unicode
        @return: the result in a specified dispaly mode.
        @rtype: according to display mode.
        )displayr3   )r7   	listtenses     r8   rV   zConjugateDisplay.display   s    ( ||DIy111r:   c                    |st           j        }|dk    r|                     |          S |dk    r|                     |          S |dk    r|                     |          S |dk    r|                     |          S |dk    r|                     |          S |dk    r|                     |          S |dk    r|                     |          S |dk    r|                     |          S |	                                d		                                k    r| 
                    |          S |d
	                                k    r|                     |          S |                     |          S )a  
        Display The conjugation result for a list of tenses, 
        with a display mode.
        Set the display mode as:
            - 'Text':
            - 'HTML':
            - 'HTMLColoredDiacritics':
            - 'DICT':
            - 'CSV':
            - 'GUI':
            - 'TABLE':
            - 'XML':
            - 'TeX':
            - 'ROWS':
        @param mode: the given mode to display result
        @type mode: unicode
        @param listtense: the given tenses list to display result
        @type listtense: list of unicode
        @return: the result in a specified dispaly mode.
        @rtype: according to display mode.
        r   HTMLHTMLColoredDiacriticsDICTCSVGUITABLEXMLTeXROWS)r"   TABLE_TENSEdisplay_textdisplay_htmldisplay_html_colored_diacriticsdisplay_dictdisplay_csvdisplay_tabledisplay_xmlupperdisplay_texdisplay_rows)r7   r3   rW   s      r8   rV   zConjugateDisplay.display   si   ,  	+*I6>>$$Y///V^^$$Y///,,,77	BBBV^^$$Y///U]]##I...U]]%%i000W__%%i000U]]##I...ZZ\\U[[]]**##I...V\\^^##$$Y///$$Y///r:   c                 0   d}| j                                         D ]}||d| j         |         dz  }|dz  }|d                    |          z  }t          j        D ]7}|d|z  z  }|D ]*}|| j        |         v r|d| j        |         |         z  z  }+8|S )z
        Display The conjugation result for a list of tenses, as text.
        @param listtense: the given tenses list to display result
        @type listtense: list of unicode
        @return: the result as text.
        @rtype: uunicode.
        r   : 
	z
%sz	%sr2   keysjoinr"   PronounsTabler0   r7   rW   r2   rJ   rP   rO   s         r8   rc   zConjugateDisplay.display_text  s     Y^^%% 	= 	=EEEE49U+;+;+;<<DD

9%%%+ 	I 	IGG((D" I Itu555G(>w(GHHDI r:   c                 :   d}| j                                         D ]}||d| j         |         dz  }|d                    |          z  }|dz  }t          j        D ]<}|d|z  z  }|D ]*}|| j        |         v r|d| j        |         |         z  z  }+|dz  }=|S )u  
        Display The conjugation result for a list of tenses, 
        as comma separeted value text.
        every line contains:
        example:
            >>> اللزوم/التعدي: متعدي
            الفعل: مَنَحَ
            نوع الفعل: فعل ثلاثي
            الماضي المعلومالمضارع المعلومالمضارع المجزومالمضارع المنصو
            بالمضارع المؤكد الثقيلالأمرالأمر المؤكدالماضي المجهولالمضارع المجهولالمضارع المجهول المجزومالمضارع المجهول المنصوبالمضارع المؤكد الثقيل المجهول 
            أنامَنَحْتُأَمْنَحُأَمْنَحْأَمْنَحَأَمْنَحَنَّمُنِحْتُأُمْنَحُأُمْنَحْأُمْنَحَأُمْنَحَنَّ
            نحنمَنَحْنَانَمْنَحُنَمْنَحْنَمْنَحَنَمْنَحَنَّمُنِحْنَانُمْنَحُنُمْنَحْنُمْنَحَنُمْنَحَنَّ
            أنتمَنَحْتَتَمْنَحُتَمْنَحْتَمْنَحَتَمْنَحَنَّاِمْنَحْاِمْنَحَنَّمُنِحْتَتُمْنَحُتُمْنَحْتُمْنَحَتُمْنَحَنَّ


        @param listtense: the given tenses list to display result
        @type listtense: list of unicode
        @return: the result as text in row.
        @rtype: unicode.
        r   rn   ro   z%srq   ru   s         r8   rg   zConjugateDisplay.display_csv.  s    * Y^^%% 	= 	=EEEE49U+;+;+;<<DD###+ 	 	GEg&&D" G Gdoe444Edoe&<W&EFFDEMDDr:   c                 f   d}d}| j         rd}t          j        D ]}|D ]}| j        |         |         dk    rx|d                    t          j        | j        |         |                   | j        |         |         t          |         t          |         || j        | j	        g          z  }|dz  }|S )a  
        Display The conjugation result for a list of tenses, as text in rows.
        every row contains:
            - unvocalized conjugation, 
            - unvocalized conjugation, 
            - pronoun
            - tense, 
            - transitive, 
            - original verb
            - tasrif bab

        @param listtense: the given tenses list to display result
        @type listtense: list of unicode
        @return: the result as text in row.
        @rtype: unicode.
        r   r!   r   rp   ro   )
r5   r"   rt   r0   rs   arabystrip_harakatTAB_DISPLAYr1   r6   )r7   rW   r2   r5   rP   rO   s         r8   rl   zConjugateDisplay.display_rowsT  s    " 
? 	J+ 	" 	"G" " "OE*73r99DII+DOE,B7,KLL.w7#G,#E*"	'   D EMD" r:   c                 T   g }g }|D ];}|t           j        v r|                    |           &|                    |           <d}|d| j        d| j        d| j        dz  }|dz  }| j                                        D ]}|d|d| j        |         d	z  }|d
z  }dD ]}|dk    r|}n|}|dz  }t          |          dk    r`|dz  }|dz  }|D ]
}|d|z  z  }|dz  }t           j        D ]2}	|dz  }|d|	z  z  }|D ]}|d| j	        |         |	         z  z  }|dz  }3|dz  }|S )z
        Display The conjugation result for a list of tenses, as HTML.
        @param listtense: the given tenses list to display result
        @type listtense: list of unicode
        # @return: the result as HTML.
        @rtype: unicode.
        r   z<h3>z : z - z</h3>
z<ul>
z<li><b>z:</b> z</li>
z</ul>

)
indicativepassiver|   z<br/>r   zI<table class = 'resultarea' border = 1
                 cellspacing = 0>
z<tr><th>&nbsp</th>z<th>%s</th>z</tr>
z<tr>z<td>&nbsp%s</td>z	</table>
)
r"   TableIndicativeTenseappendr1   r4   r2   rr   lenrt   r0   )
r7   rW   indicative_tensespassive_tensesrO   r2   rJ   r3   listtense_to_displayrP   s
             r8   rd   zConjugateDisplay.display_html|  s     	- 	-E333!((////%%e,,,,tyyy$))) 	 		Y^^%% 	M 	MEDEEE49U;K;K;KLLDD- 	& 	&T|##'8$$ (6$'((!++ ' '--1 6 6ENu55DD
"%3 ' 'GGODNw77D!5 9 9 3.w7!9 9J&DD%r:   c                 Z    |                      |          }|                     |          }|S )a  
        Display The conjugation result for a list of tenses, 
        as HTML with colored vocalization.
        @param listtense: the given tenses list to display result
        @type listtense: list of unicode
        @return: the result as HTML.
        @rtype: unicode.
        )rd   highlight_diacritics_html)r7   rW   r2   s      r8   re   z0ConjugateDisplay.display_html_colored_diacritics  s/       ++--d33r:   c                    d}d}d}t          t          |                    D ]:}||         t          j        t          j        t          j        t          j        fv r|dk    r||dz
           t          j        t          j        t          j	        t          j
        t          j        t          j        t          j        t          j        t          j        t          j        f
vrQ|dz   t          |          k     r;||dz            dvr.|d                    |t          j        ||         |g          z  }|d                    |d||         |g          z  }/|||         z  }<|S )z
        Highlight dfiactitics in the HTML text.
        @param text: the given text
        @type text: unicode.
        @return: the result as HTML.
        @rtype: unicode.
        r   z<span class = 'tashkeel'>z</span>r      ) <r   )ranger   rx   FATHADAMMAKASRASUKUNALEFALEF_HAMZA_ABOVE	WAW_HAMZA
ALEF_MADDADALTHALWAWREHZAINSHADDArs   TATWEEL)r7   r2   
hight_textlefttagrighttagis         r8   r   z*ConjugateDisplay.highlight_diacritics_html  s3    
.s4yy!! 	& 	&AAw5;U[%+NNNaCCD1Iej&9IEJ	59ejL.   !"!CII$qs):2M2M#((GU]GX,' #( #( (JJ #((GS$q'8+L"M"MMJJd1g%

r:   c                    i }d}ddi|d<   t          t          |                    D ]}||         |d         |dz   <   d}t          j        D ]?}i ||<   |||         d<   d}|D ]#}| j        |         |         ||         |<   |dz   }$|dz   }@|S )a!  Display The conjugation result for a list of tenses, as array.
        @param listtense: the given tenses list to display result
        @type listtense: list of unicode
        @return: the result as table, the table[0] contains pronouns.
        @rtype: dict with number indice.
        r   u   الضمائرr   )r   r   r"   rt   r0   )r7   rW   tablejr   rP   rO   s          r8   rh   zConjugateDisplay.display_table  s     '(as9~~&& 	) 	)A%aLE!HQqSMM+ 	 	GE!H!E!HQKA"  "oe4W=aaC!AAr:   c                 4    i }|D ]}| j         |         ||<   |S )a  
        Display The conjugation result for a list of tenses, as python dict.
        @param listtense: the given tenses list to display result
        @type listtense: list of unicode
        @return: the result as python dict.
        @rtype: dict.
        rN   )r7   rW   r   rO   s       r8   rf   zConjugateDisplay.display_dict  s/      	2 	2E?51E%LLr:   c                 H   d}|dz  }|d| j         z  z  }| j                                        D ]}|d|d| j        |         dz  }|D ]R}|d|z  z  }t          j        D ]6}| j        |         |         dk    r|d|d| j        |         |         d	z  }7|d
z  }S|dz  }|S )z
        Display The conjugation result for a list of tenses, as XML.
        @param listtense: the given tenses list to display result
        @type listtense: list of unicode
        @return: the result as XML.
        @rtype: unicode.
        r   z<verb_conjugation>
z(	<proprety name = 'verb' value = '%s'/>
z	<proprety name = 'z' value = 'z'/>
z	<tense name = '%s'>
z		<conjugation pronoun = 'z'
                    />
z
	</tense>
z</verb_conjugation>r1   r2   rr   r"   rt   r0   r7   rW   r2   rJ   rO   rP   s         r8   ri   zConjugateDisplay.display_xml  s     ''=$)LLY^^%% 	 	EDEEEYu DD 	$ 	$E.599D!/ J J?5)'2b88D ')?)H)H)HJ JDO#DD&&r:   c                    d}|dz  }|dz  }|d| j         z  z  }|dz  }| j                                        D ]7}|dk    r|d|d| j        |         d	z  } |d|d
| j        |         dz  }8|dz  }|dz  }|dz  }|D ]
}|d|z  z  }|dz  }t          j        D ]-}|d|z  z  }|D ]}|d| j        |         |         z  z  }|dz  }.|dz  }|dz  }|dz  }|S )z
        Display The conjugation result for a list of tenses, as TeX.
        @param listtense: the given tenses list to display result
        @type listtense: list of unicode
        @return: the result as TeX format.
        @rtype: unicode.
        r   z\environment qutrub-layout
z\starttext
z\Title{%s}
z\startitemize
u,    الكتابة الداخلية للفعل z\item {\bf z} \DeShape{z}
z} ro   z\stopitemize
z\starttable[|lB|l|l|l|l|l|]
z
\HL[3]
\NCz\NC {\bf %s}z\SR
\HL
z\NC %sz\AR
z
\LR\HL[3]
z\stoptable
z	\stoptextr   r   s         r8   rk   zConjugateDisplay.display_tex  s    00   TY//##Y^^%% 	N 	NEGGG5!!!# # UUUDIe<L<L<LMM""11   	1 	1E%%00DD+ 	 	GJ7++D" H H
tu'=g'FGGIDD    r:   )N) __name__
__module____qualname____doc__r0   pronounsr1   r3   r4   r2   r5   r9   r=   r?   rA   rC   rE   rH   rL   rQ   rT   rV   rc   rg   rl   rd   re   r   rh   rf   ri   rk    r:   r8   r   r   J   s         JHDDKDJ  4    "  
  ' ' '  
% 
% 
%   9 9 9"2 2 2 2*-0 -0 -0 -0^  *! ! !L% % %P/ / /b    4  0    0% % % % %r:   r   )#r   libqutrub.verb_const
verb_constr"   pyarabic.arabyrx   r$   
PronounAnaPronounNahnuPronounAntaPronounAntiPronounAntumaPronounAntuma_fPronounAntumPronounAntunnaPronounHuwa
PronounHyaPronounHumaPronounHuma_f
PronounHumPronounHunnar#   r'   r-   r/   r)   r+   r.   r&   r(   r*   r,   TensePassiveConfirmedFuturerz   r   r   r:   r8   <module>r      s  .  & % % % % %        "brB	BB2Rb2L L    $   D   4   6	 
  T   t   D   d   4   %   5   U   %   E $  % &  5' (  u) *    %  e  E    %     $U  "5?   Dn n n n n n n n n nr:   