
    -iA                         d Z ddlmZmZmZmZ edk    rddlZej        	                    d           d Z
ddlmZ  G d	 d
          Zedk    r ed           dS dS )zQ
synNode represents the regrouped data resulted from the 
morpholocigal analysis
    )absolute_importprint_functionunicode_literalsdivision__main__Nz../libc                 
    | dv S )Nu$   !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~،؟ words    N/var/www/html/speakWrite/venv/lib/python3.11/site-packages/sylajone/synnode.pyispunctr      s    <<<       )	syn_constc                       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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%S )&SynNodez]
    synNode represents the regrouped data resulted from the 
    morpholocigal analysis
    c                 j   t          |          | _        d| _        i | _        i | _        g | _        |rPd |D             | _        t          t          | j                            | _        | j                                         i | _	        d| _
        d| _        g g g g d| _        g g g g d| _        g | _        g | _        g g g g g g g d| _        i | _        i | _        i | _        i | _        t          t+          t          |                              | _        |r|d                                         | _        |D ]}|                                }|                                | j	        v r3| j	        |                                                             |           n|g| j	        |                                <   |                                r | j        d                             |           |                                r | j        d                             |           |                                r | j        d	                             |           |                                r | j        d
                             |           |                                r| j                            |           n| j                            |           | j        r!tA          | j        d                   rd| _        |!                                r|"                                r"| j        d                             |           n>|#                                r"| j        d                             |           n|$                                r | j        d                             |           n|"                                r!| j        d                             |           n|#                                r!| j        d                             |           ni|$                                r!| j        d                             |           n4|%                                r | j        d                             |           |&                                r|'                                | j        |<   |(                                r|)                                | j        |<   |*                                r|+                                | j        |<   |,                                r|-                                | j        |<   t          | j        d                   t          | j        d                   t          | j        d	                   t          | j        d
                   d| _        dS )zI
        Create the synNode  from a list of StemmedSynword cases
         c                 6    g | ]}|                                 S r	   )get_vocalized).0cases     r   
<listcomp>z$SynNode.__init__.<locals>.<listcomp>5   s$    JJJt1133JJJr   F)verbnounpounctstopword)mansoubmarfou3majrourmajzoumtanwin_mansoubtanwin_marfou3tanwin_majrourr   r   r   r   r   Tr"   r#   r$   r   r   r    r!   )r   r   r   r   N).len
case_countr   previous_nodes
next_nodes
vocalizedslistsetsort	originalsguessed_type_tag	break_end	word_typecountbreaks
non_breakssyntax_marksyn_previous	syn_nextssem_previous	sem_nextsrangechosen_indexesget_word	get_orderget_originalappendis_verbis_nounis_stopword	is_pounctis_breakr   	is_tanwin
is_mansoub
is_marfou3
is_majrour
is_majzoumhas_previousget_previoushas_nextget_nexthas_sem_previousget_sem_previoushas_sem_nextget_sem_next)self	case_listr   idxs       r   __init__zSynNode.__init__&   sc    i.. 	  	#JJ	JJJDO"3t#7#788DOO  """  !#
 "$!!##% 
  !!##% 
 &("$"$"$)+)+)+   #5Y#8#899
  	0!!--//DI 0	: 0	:D..""C  ""dn44t00223::3????7:gt00223||~~ 3v&--c222||~~ 3v&--c222!! 7z*11#666~~ 5x(//444}} ,""3''''&&s+++y &WTYq\22 &!%~~ <??$$ C$%56==cBBBB__&& C$%56==cBBBB__&& C$%56==cBBB??$$ <$Y/66s;;;;__&& <$Y/66s;;;;__&& <$Y/66s;;;;__&& <$Y/66s;;;  "" =)-):):)<)<!#&}} 6&*mmoos#$$&& A)-)>)>)@)@!#&  "" :&*&7&7&9&9s# !788v 677!$T^J%?!@!@!$.":;;
 



r   c                     || _         dS )zz
        Set the case count.
        @param count: the number of stemmed word  cases
        @tyep count: integer
        Nr&   rQ   r1   s     r   set_case_countzSynNode.set_case_count   s      r   c                     | j         S )zu
        get the case count.
        @return: the number of stemmed word  cases
        @tyep count: integer
        rV   rQ   s    r   get_case_countzSynNode.get_case_count        r   c                     || _         dS )zk
        Set the guessed type tag.
        @param tag: guessed type tag
        @type tag: unicode
        Nr.   )rQ   tags     r   set_guessed_type_tagzSynNode.set_guessed_type_tag   s     !$r   c                     | j         S )ze
        get the guessed type tag.
        @return: guessed type tag
        @rtype: unicode
        r^   rZ   s    r   get_guessed_type_tagzSynNode.get_guessed_type_tag        $$r   c                     | j         S )zq
        get the guessed type tag.
        @return: guessed type tag
        @rtype tag: unicode        
        r^   rZ   s    r   r[   zSynNode.get_case_count   rc   r   c                     || j         d<   dS )z
        Set the verb count.
        @param count: the number of stemmed word cases as  verbs
        @tyep count: integer
        r   Nr1   rW   s     r   set_verb_countzSynNode.set_verb_count        #
6r   c                     | j         d         S )z}
        get the verb count.
        @return: the number of stemmed word cases as verbs
        @tyep count: integer
        r   rf   rZ   s    r   get_verb_countzSynNode.get_verb_count        z&!!r   c                     || j         d<   dS )z
        Set the noun count.
        @param count: the number of stemmed word cases as  nouns
        @tyep count: integer
        r   Nrf   rW   s     r   set_noun_countzSynNode.set_noun_count   rh   r   c                     | j         d         S )z}
        get the noun count.
        @return: the number of stemmed word cases as nouns
        @tyep count: integer
        r   rf   rZ   s    r   get_noun_countzSynNode.get_noun_count   rk   r   c                     || j         d<   dS )z
        Set the stopword count.
        @param count: the number of stemmed word cases as  stopwords
        @tyep count: integer
        r   Nrf   rW   s     r   set_stopword_countzSynNode.set_stopword_count   s     "'
:r   c                     | j         d         S )z
        get the stopword count.
        @return: the number of stemmed word cases as stopwords
        @tyep count: integer
        r   rf   rZ   s    r   get_stopword_countzSynNode.get_stopword_count   s     z*%%r   c                     | j         S )zr
        Get the input word given by user
        @return: the given word.
        @rtype: unicode string
        r
   rZ   s    r   r;   zSynNode.get_word   s     yr   c                     || _         dS )z
        Set the input word given by user
        @param newword: the new given word.
        @type newword: unicode string
        Nr
   )rQ   newwords     r   set_wordzSynNode.set_word  s     			r   c                 N    t          | j                                                  S )z~
        Get the original forms of the input word
        @return: the given original.
        @rtype: unicode string
        )r*   r-   keysrZ   s    r   r=   zSynNode.get_original  s      DN''))***r   c                     | j         S )z
        Get the vocalized forms of the input word
        @return: the given vocalizeds.
        @rtype: list of unicode string
        )r)   rZ   s    r   get_vocalizedszSynNode.get_vocalizeds  r\   r   c                     | j         S )
        Get the chosen_indexes forms of the input word
        @return: the given chosen_indexes.
        @rtype: unicode string
        )r:   rZ   s    r   get_chosen_indexeszSynNode.get_chosen_indexes  s     ""r   c                 F    |D ]}|| j         k    s|dk     r dS || _        dS )r}   r   N)r&   r:   )rQ   indexesis      r   set_chosen_indexeszSynNode.set_chosen_indexes"  sD      	* 	*ADO##q1uu (- #*Dr   c                 $    | j         d         dk    S )z
        Return if all cases are verbs.
        @return:True if the node has verb in one case at least.
        @rtype:boolean
        r   r   rf   rZ   s    r   has_verbzSynNode.has_verb2       z&!A%%r   c                 $    | j         d         dk    S )z
        Return if all cases are nouns.
        @return:True if the node has noun in one case at least.
        @rtype:boolean
        r   r   rf   rZ   s    r   has_nounzSynNode.has_noun:  r   r   c                 $    | j         d         dk    S )z
        Return if all cases are stopwords.
        @return:True if the node has stopword in one case at least.
        @rtype:boolean
        r   r   rf   rZ   s    r   has_stopwordzSynNode.has_stopwordB  s     z*%))r   c                 $    | j         d         dk    S )z
        Return if all cases are pounctuations
        @return:True if the node has pounctation in one case at least.
        @rtype:boolean
        r   r   rf   rZ   s    r   	has_punctzSynNode.has_punctJ  s     z(#a''r   c                 p    | j         d         o)| j         d          o| j         d          o| j         d          S )z
        Return if all cases are verbs.
        @return:True if the node is verb in alll cases.
        @rtype:boolean
        r   r   r   r   rf   rZ   s    r   r?   zSynNode.is_verbR  sH     
6"  4:h+?'?  
S]H^D^  Z		"r   c                 p    | j         d          o(| j         d          o| j         d          o| j         d         S )z
        Return if all cases are nouns.
        @return:True if the node is noun in alll cases.
        @rtype:boolean
        r   r   r   r   rf   rZ   s    r   r@   zSynNode.is_noun[  sK     :h'' 3J1G-G 3
6O 3 $
6 2	3r   c                 p    | j         d          o(| j         d         o| j         d          o| j         d          S )z
        Return if all cases are stopwords.
        @return:True if the node is stopword in alll cases.
        @rtype:boolean
        r   r   r   r   rf   rZ   s    r   rA   zSynNode.is_stopworde  sH     :h'' ;DJz,B ;Jv;(,
6(:$:	;r   c                 p    | j         d         o)| j         d          o| j         d          o| j         d          S )z
        Return if all cases are pounctuations
        @return:True if the node is pounctation in alll cases.
        @rtype:boolean
        r   r   r   r   rf   rZ   s    r   rB   zSynNode.is_pounctn  sI     
8$ ?TZ
-C)C ?
6""?,0Jv,>(>	Ar   c                 r    | j         d         | j         d         k    o| j         d         | j         d         k    S )z
        Return True if most  cases are verbs.
        @return:True if the node is verb in most cases.
        @rtype:boolean
        r   r   r   rf   rZ   s    r   is_most_verbzSynNode.is_most_verbw  s:     z&!DJv$66 4
6TZ
33	4r   c                 r    | j         d         | j         d         k    o| j         d         | j         d         k    S )z
        Return True if most  cases are nouns.
        @return:True if the node is noun in most cases.
        @rtype:boolean
        r   r   r   rf   rZ   s    r   is_most_nounzSynNode.is_most_noun  s:     
6"TZ%77 4
6TZ
33	5r   c                 r    | j         d         | j         d         k    o| j         d         | j         d         k    S )z
        Return True if most cases are stopwords.
        @return:True if the node is stopword in most cases.
        @rtype:boolean
        r   r   r   rf   rZ   s    r   is_most_stopwordzSynNode.is_most_stopword  s:     z*%
6(:: 4
:F!33	4r   c                 :   |                                  rdS |                                 rdS |                                 rdS |                                 rdS |                                 rdS |                                 rdS |                                 rdS dS )	zh
        Return the word type.
        @return:the word type or mosttype.
        @rtype:string
        r   r   r   r   mostnounmostverbmoststopword	ambiguous)r@   r?   rA   rB   r   r   r   rZ   s    r   get_word_typezSynNode.get_word_type  s     <<>> 	6\\^^ 	6 	:^^ 		8   	:   	:""$$ 	!>;r   c                 >   | j         r	| j        sdS |                                 r| j        s	| j        sdS | j        r	| j         sdS t          | j                  t          | j                   k    rdS t          | j                  t          | j                   k     rdS dS )z
        Return the word break type, 
        if the word break the sentences or not.
        @return:the word type or mosttype.
        @rtype:string
        break	non_breakmostNon_break
most_breakr   )r2   r3   r   r7   r8   r%   rZ   s    r   get_break_typezSynNode.get_break_type  s     ; 	t 	7   		): 		4> 		7_ 	T[ 	;!!C$4$444"?!!C$4$444<;r   c                     | j         S )z
        The syn node is break end like puctuation, if it  hasn't any syntaxique or semantique 
        relation with the previous word
        )r/   rZ   s    r   is_break_endzSynNode.is_break_end  s     ~r   c                 .    |                                  dv S )z{
        The syn node is break, if it hasn't any syntaxique or semantique 
        relation with the previous word
        )r   	mostBreak)r   rZ   s    r   rC   zSynNode.is_break  s     ""$$(>>>r   c                     | j         s	| j        sdS | j         D ]%}| j         t                   t          j        k    r dS &dS )z|
        The syn node is next break, if it hasn't any syntaxique or semantique 
        relation with the next word
        TF)r6   r8   kr   TanwinRelation)rQ   keys     r   is_next_breakzSynNode.is_next_break  sV    
 ~ 	! 	!4 ~ ! !>!$	(@@@ 55 Aur   c           	      P   d| j         d         d                    | j                  |                                 |                                 | j        d         | j        d         | j        d         fz  }|t          | j                  z  }|dt          | j                  z   z  }|S )Nz$
'%s':%s, [%s-%s]{V:%d, N:%d, S:%d} r   z, r   r   r   z
Indexes : )	__dict__joinr-   r   r   r1   reprr4   r:   )rQ   texts     r   __repr__zSynNode.__repr__  s    7M&!5::dn#=#=  $"5"5"7"7F9KJv
: 6;: : 	T%&&&d4#67777r   N)&__name__
__module____qualname____doc__rT   rX   r[   r`   rb   rg   rj   rm   ro   rq   rs   r;   rw   r=   r{   r~   r   r   r   r   r   r?   r@   rA   rB   r   r   r   r   r   r   rC   r   r   r	   r   r   r   r   !   s2        }
 }
 }
J       $ $ $% % %% % %# # #" " "# # #" " "' ' '& & &    + + +  # # #* * * & & && & &* * *( ( (" " "3 3 3; ; ;A A A4 4 45 5 54 4 4  .  0  ? ? ?      r   r   zSyn Node module)r   
__future__r   r   r   r   r   syspathr>   r   r   r   r   printr	   r   r   <module>r      s                zJJJHOOH= = =      F F F F F F F FP z	E r   