o
    rZh                     @   sz   d dl mZ d dlmZmZ d dlmZ G dd deZG dd deeZG dd	 d	eeZ	G d
d deeZ
g dZdS )    )ProbabilisticMixIn)MultiParentedTreeParentedTree)Treec                       s   e Zd Zd  fdd	Zdd Zdd Zdd	 Zd
d Zdd Zdd Z	dd Z
dd Zd ddZdd Zdd Zdd Zdd Zdd Z  ZS )!ImmutableTreeNc              
      sZ   t  || zt| jt| f| _W d S  ttfy, } z
tdt| j	 |d }~ww )Nz-%s: node value and children must be immutable)
super__init__hash_labeltuple_hash	TypeError
ValueErrortype__name__)selfnodechildrene	__class__ B/var/www/auris/lib/python3.10/site-packages/nltk/tree/immutable.pyr      s   zImmutableTree.__init__c                 C      t dt| j N%s may not be modifiedr   r   r   )r   indexvaluer   r   r   __setitem__      zImmutableTree.__setitem__c                 C   r   r   r   )r   ijr   r   r   r   __setslice__   r    zImmutableTree.__setslice__c                 C   r   r   r   )r   r   r   r   r   __delitem__"   r    zImmutableTree.__delitem__c                 C   r   r   r   )r   r!   r"   r   r   r   __delslice__%   r    zImmutableTree.__delslice__c                 C   r   r   r   r   otherr   r   r   __iadd__(   r    zImmutableTree.__iadd__c                 C   r   r   r   r&   r   r   r   __imul__+   r    zImmutableTree.__imul__c                 C   r   r   r   r   vr   r   r   append.   r    zImmutableTree.appendc                 C   r   r   r   r*   r   r   r   extend1   r    zImmutableTree.extendc                 C   r   r   r   r*   r   r   r   pop4   r    zImmutableTree.popc                 C   r   r   r   r*   r   r   r   remove7   r    zImmutableTree.removec                 C   r   r   r   r   r   r   r   reverse:   r    zImmutableTree.reversec                 C   r   r   r   r0   r   r   r   sort=   r    zImmutableTree.sortc                 C   s   | j S N)r   r0   r   r   r   __hash__@   s   zImmutableTree.__hash__c                 C   s&   t | drtdt| j || _dS )z
        Set the node label.  This will only succeed the first time the
        node label is set, which should occur in ImmutableTree.__init__().
        r
   r   N)hasattrr   r   r   r
   )r   r   r   r   r   	set_labelC   s   

zImmutableTree.set_labelr3   )r   
__module____qualname__r   r   r#   r$   r%   r(   r)   r,   r-   r.   r/   r1   r2   r4   r6   __classcell__r   r   r   r   r      s     
r   c                   @   sD   e Zd ZdddZdd Zdd Zdd	 ZdddZedd Z	dS )ImmutableProbabilisticTreeNc                 K   s>   t | || tj| fi | t| jt| |  f| _d S r3   )r   r   r   r	   r
   r   probr   )r   r   r   Zprob_kwargsr   r   r   r   N   s   z#ImmutableProbabilisticTree.__init__c                 C   s   t S r3   )r:   r0   r   r   r   _frozen_classT   s   z(ImmutableProbabilisticTree._frozen_classc                 C   s   t |  d|   dS )N [])r   __repr__r;   r0   r   r   r   r?   W   s   z#ImmutableProbabilisticTree.__repr__c                 C   s   | j dd d|   dS )N<   )marginr=   r>   )pformatr;   r0   r   r   r   __str__Z   s   z"ImmutableProbabilisticTree.__str__Fc                 C   s*   |st | | j| |  dS t | | S )Nr;   )r   r
   r;   convert)r   deepr   r   r   copy]   s   zImmutableProbabilisticTree.copyc                    sN   t |tr% fdd|D }t |tr |j|| dS  |j|ddS |S )Nc                    s   g | ]}  |qS r   )rE   ).0childclsr   r   
<listcomp>f   s    z6ImmutableProbabilisticTree.convert.<locals>.<listcomp>rD   g      ?)
isinstancer   r   r
   r;   )rK   valr   r   rJ   r   rE   c   s   

z"ImmutableProbabilisticTree.convertr3   )F)
r   r7   r8   r   r<   r?   rC   rG   classmethodrE   r   r   r   r   r:   M   s    

r:   c                   @      e Zd ZdS )ImmutableParentedTreeNr   r7   r8   r   r   r   r   rQ   o       rQ   c                   @   rP   )ImmutableMultiParentedTreeNrR   r   r   r   r   rT   s   rS   rT   )r:   r   rQ   rT   N)Znltk.probabilityr   Znltk.tree.parentedr   r   Znltk.tree.treer   r   r:   rQ   rT   __all__r   r   r   r   <module>   s   
="