§
    'ê[fÚ%  ã                   ó4   — d dl mZmZ  G d„ de¬¦  «        ZdS )é    )ÚABCMetaÚabstractmethodc                   ó²   — e Zd ZdZdZdZdd„Zd„ Zed„ ¦   «         Z	d„ Z
edd	„¦   «         Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zeed„ ¦   «         ¦   «         ZdS )ÚFeaturea  
    An abstract base class for Features. A Feature is a combination of
    a specific property-computing method and a list of relative positions
    to apply that method to.

    The property-computing method, M{extract_property(tokens, index)},
    must be implemented by every subclass. It extracts or computes a specific
    property for the token at the current index. Typical extract_property()
    methods return features such as the token text or tag; but more involved
    methods may consider the entire sequence M{tokens} and
    for instance compute the length of the sentence the token belongs to.

    In addition, the subclass may have a PROPERTY_NAME, which is how
    it will be printed (in Rules and Templates, etc). If not given, defaults
    to the classname.

    znltk.tbl.FeatureNc                 ó~  — d| _         |€,t          t          d„ |D ¦   «         ¦  «        ¦  «        | _         nj	 ||k    rt          ‚t          t	          ||dz   ¦  «        ¦  «        | _         n6# t          $ r)}t          d                     ||¦  «        ¦  «        |‚d}~ww xY w| j        j        p| j        j	        | _        dS )al  
        Construct a Feature which may apply at C{positions}.

        >>> # For instance, importing some concrete subclasses (Feature is abstract)
        >>> from nltk.tag.brill import Word, Pos

        >>> # Feature Word, applying at one of [-2, -1]
        >>> Word([-2,-1])
        Word([-2, -1])

        >>> # Positions need not be contiguous
        >>> Word([-2,-1, 1])
        Word([-2, -1, 1])

        >>> # Contiguous ranges can alternatively be specified giving the
        >>> # two endpoints (inclusive)
        >>> Pos(-3, -1)
        Pos([-3, -2, -1])

        >>> # In two-arg form, start <= end is enforced
        >>> Pos(2, 1)
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
          File "nltk/tbl/template.py", line 306, in __init__
            raise TypeError
        ValueError: illegal interval specification: (start=2, end=1)

        :type positions: list of int
        :param positions: the positions at which this features should apply
        :raises ValueError: illegal position specifications

        An alternative calling convention, for contiguous positions only,
        is Feature(start, end):

        :type start: int
        :param start: start of range where this feature should apply
        :type end: int
        :param end: end of range (NOTE: inclusive!) where this feature should apply
        Nc                 ó,   — h | ]}t          |¦  «        ’ŒS © )Úint)Ú.0Úis     úD/var/www/piapp/venv/lib/python3.11/site-packages/nltk/tbl/feature.pyú	<setcomp>z#Feature.__init__.<locals>.<setcomp>M   s   € Ð*EÐ*EÐ*E°a­3¨q©6¬6Ð*EÐ*EÐ*Eó    é   z2illegal interval specification: (start={}, end={}))
Ú	positionsÚtupleÚsortedÚ	TypeErrorÚrangeÚ
ValueErrorÚformatÚ	__class__ÚPROPERTY_NAMEÚ__name__)Úselfr   ÚendÚes       r   Ú__init__zFeature.__init__#   sØ   € ðP ˆŒØˆ;Ý"¥6Ð*EÐ*E¸9Ð*EÑ*EÔ*EÑ#FÔ#FÑGÔGˆDŒNˆNð
Ø˜s’?�?Ý#�OÝ!&¥u¨Y¸¸a¹Ñ'@Ô'@Ñ!AÔ!A�”�øÝð ð ð å ØH×OÒOØ! 3ñô ñô ð ð	øøøøðøøøð "œ^Ô9ÐT¸T¼^Ô=TˆÔÐÐs   ·2A* Á*
BÁ4$BÂBc                 ó   — | j         S ©N)r   ©r   s    r   Úencode_json_objzFeature.encode_json_obj^   s
   € ØŒ~Ðr   c                 ó   — |} | |¦  «        S r    r	   )ÚclsÚobjr   s      r   Údecode_json_objzFeature.decode_json_obja   s   € àˆ	Øˆs�9‰~Œ~Ðr   c                 óJ   — | j         j        › dt          | j        ¦  «        ›d�S )Nú(ú))r   r   Úlistr   r!   s    r   Ú__repr__zFeature.__repr__f   s(   € Ø”.Ô)ÐEÐE­D°´Ñ,@Ô,@ÐEÐEÐEÐEr   Fc                 ó˜   ‡ ‡‡— t          d„ |D ¦   «         ¦  «        st          d|› �¦  «        ‚ˆfd„|D ¦   «         }ˆ ˆfd„|D ¦   «         S )a¼  
        Return a list of features, one for each start point in starts
        and for each window length in winlen. If excludezero is True,
        no Features containing 0 in its positions will be generated
        (many tbl trainers have a special representation for the
        target feature at [0])

        For instance, importing a concrete subclass (Feature is abstract)

        >>> from nltk.tag.brill import Word

        First argument gives the possible start positions, second the
        possible window lengths

        >>> Word.expand([-3,-2,-1], [1])
        [Word([-3]), Word([-2]), Word([-1])]

        >>> Word.expand([-2,-1], [1])
        [Word([-2]), Word([-1])]

        >>> Word.expand([-3,-2,-1], [1,2])
        [Word([-3]), Word([-2]), Word([-1]), Word([-3, -2]), Word([-2, -1])]

        >>> Word.expand([-2,-1], [1])
        [Word([-2]), Word([-1])]

        A third optional argument excludes all Features whose positions contain zero

        >>> Word.expand([-2,-1,0], [1,2], excludezero=False)
        [Word([-2]), Word([-1]), Word([0]), Word([-2, -1]), Word([-1, 0])]

        >>> Word.expand([-2,-1,0], [1,2], excludezero=True)
        [Word([-2]), Word([-1]), Word([-2, -1])]

        All window lengths must be positive

        >>> Word.expand([-2,-1], [0])
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
          File "nltk/tag/tbl/template.py", line 371, in expand
            :param starts: where to start looking for Feature
        ValueError: non-positive window length in [0]

        :param starts: where to start looking for Feature
        :type starts: list of ints
        :param winlens: window lengths where to look for Feature
        :type starts: list of ints
        :param excludezero: do not output any Feature with 0 in any of its positions.
        :type excludezero: bool
        :returns: list of Features
        :raises ValueError: for non-positive window lengths
        c              3   ó"   K  — | ]
}|d k    V — ŒdS )r   Nr	   )r   Úxs     r   ú	<genexpr>z!Feature.expand.<locals>.<genexpr>Ÿ   s&   è è € Ð*Ð*˜Q�1�q’5Ð*Ð*Ð*Ð*Ð*Ð*r   znon-positive window length in c              3   ó|   •K  — | ]6}t          t          ‰¦  «        |z
  d z   ¦  «        D ]}‰|||z   …         V — ŒŒ7dS )r   N)r   Úlen)r   Úwr   Ústartss      €r   r/   z!Feature.expand.<locals>.<genexpr>¡   sU   øè è € ÐUÐU A½%ÅÀFÁÄÈaÁÐRSÑ@SÑ:TÔ:TÐUÐU°Qˆf�Q˜˜Q™�YÔÐUÐUÐUÐUÐUÐUÐUr   c                 ó2   •— g | ]}‰rd |v ° ‰|¦  «        ‘ŒS )r   r	   )r   r.   r$   Úexcludezeros     €€r   ú
<listcomp>z"Feature.expand.<locals>.<listcomp>¢   s+   ø€ ÐCÐCÐC˜1¨;ÐC¸1À¸6¸6���A‘”¸6¸6¸6r   )Úallr   )r$   r3   Úwinlensr5   Úxss   `` ` r   ÚexpandzFeature.expandi   su   øøø€ õl Ð*Ð* 'Ð*Ñ*Ô*Ñ*Ô*ð 	IÝÐG¸gÐGÐGÑHÔHÐHØUÐUÐUÐU¨ÐUÑUÔUˆØCÐCÐCÐCÐC ÐCÑCÔCÐCr   c                 ór   — | j         |j         u o)t          | j        ¦  «        t          |j        ¦  «        k    S )aQ  
        Return True if this Feature always returns True when other does

        More precisely, return True if this feature refers to the same property as other;
        and this Feature looks at all positions that other does (and possibly
        other positions in addition).

        #For instance, importing a concrete subclass (Feature is abstract)
        >>> from nltk.tag.brill import Word, Pos

        >>> Word([-3,-2,-1]).issuperset(Word([-3,-2]))
        True

        >>> Word([-3,-2,-1]).issuperset(Word([-3,-2, 0]))
        False

        #Feature subclasses must agree
        >>> Word([-3,-2,-1]).issuperset(Pos([-3,-2]))
        False

        :param other: feature with which to compare
        :type other: (subclass of) Feature
        :return: True if this feature is superset, otherwise False
        :rtype: bool


        )r   Úsetr   ©r   Úothers     r   Ú
issupersetzFeature.issuperset¤   s>   € ð8 Œ~ ¤Ð0ð 
µS¸¼Ñ5HÔ5HÍCØŒOñM
ô M
ò 6
ð 	
r   c                 óŠ   — t          | j        |j        u o(t          | j        ¦  «        t          |j        ¦  «        z  ¦  «        S )a�  
        Return True if the positions of this Feature intersects with those of other

        More precisely, return True if this feature refers to the same property as other;
        and there is some overlap in the positions they look at.

        #For instance, importing a concrete subclass (Feature is abstract)
        >>> from nltk.tag.brill import Word, Pos

        >>> Word([-3,-2,-1]).intersects(Word([-3,-2]))
        True

        >>> Word([-3,-2,-1]).intersects(Word([-3,-2, 0]))
        True

        >>> Word([-3,-2,-1]).intersects(Word([0]))
        False

        #Feature subclasses must agree
        >>> Word([-3,-2,-1]).intersects(Pos([-3,-2]))
        False

        :param other: feature with which to compare
        :type other: (subclass of) Feature
        :return: True if feature classes agree and there is some overlap in the positions they look at
        :rtype: bool
        )Úboolr   r<   r   r=   s     r   Ú
intersectszFeature.intersectsÄ   sC   € õ: ØŒN˜eœoÐ-ð ;Ý�D”NÑ#Ô#¥c¨%¬/Ñ&:Ô&:Ñ:ñ
ô 
ð 	
r   c                 ó>   — | j         |j         u o| j        |j        k    S r    )r   r   r=   s     r   Ú__eq__zFeature.__eq__è   s   € ØŒ~ ¤Ð0ÐV°T´^ÀuÄÒ5VÐVr   c                 óV   — | j         j        |j         j        k     p| j        |j        k     S r    )r   r   r   r=   s     r   Ú__lt__zFeature.__lt__ë   s,   € àŒNÔ# e¤oÔ&>Ò>ð -ð ŒN˜Uœ_Ò,ð		
r   c                 ó   — | |k     S r    r	   r=   s     r   Ú__ne__zFeature.__ne__ó   s   € Ø˜E’MÐ"Ð"r   c                 ó   — || k     S r    r	   r=   s     r   Ú__gt__zFeature.__gt__ö   s   € Ø�tŠ|Ðr   c                 ó   — | |k      S r    r	   r=   s     r   Ú__ge__zFeature.__ge__ù   s   € Ø˜%’<ÐÐr   c                 ó   — | |k     p| |k    S r    r	   r=   s     r   Ú__le__zFeature.__le__ü   s   € Ø�eŠ|Ð,˜t uš}Ð,r   c                 ó   — dS )a@  
        Any subclass of Feature must define static method extract_property(tokens, index)

        :param tokens: the sequence of tokens
        :type tokens: list of tokens
        :param index: the current index
        :type index: int
        :return: feature value
        :rtype: any (but usually scalar)
        Nr	   )ÚtokensÚindexs     r   Úextract_propertyzFeature.extract_propertyÿ   s   € € € r   r    )F)r   Ú
__module__Ú__qualname__Ú__doc__Újson_tagr   r   r"   Úclassmethodr&   r+   r:   r?   rB   rD   rF   rH   rJ   rL   rN   Ústaticmethodr   rR   r	   r   r   r   r      sF  € € € € € ðð ð$ "€HØ€Mð9Uð 9Uð 9Uð 9Uðvð ð ð ðð ñ „[ððFð Fð Fð ð8Dð 8Dð 8Dñ „[ð8Dðt
ð 
ð 
ð@ 
ð  
ð  
ðHWð Wð Wð
ð 
ð 
ð#ð #ð #ðð ð ð ð  ð  ð-ð -ð -ð Øð
ð 
ñ „^ñ „\ð
ð 
ð 
r   r   )Ú	metaclassN)Úabcr   r   r   r	   r   r   ú<module>r[      sc   ðð (Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'ð~ð ~ð ~ð ~ð ~˜ð ~ñ ~ô ~ð ~ð ~ð ~r   