Ë
    çÍ:jÏ$  ã                   ó,   — d dl mZmZ  G d„ de¬«      Zy)é    )Ú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y)Ú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| _         |€1t        t        |D �ch c]  }t        |«      ’Œ c}«      «      | _         n)	 ||kD  rt        ‚t        t        ||dz   «      «      | _         | j                  j                  xs | j                  j                  | _	        yc c}w # t        $ r!}t        dj                  ||«      «      |‚d}~ww xY w)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
        Né   z2illegal interval specification: (start={}, end={}))Ú	positionsÚtupleÚsortedÚintÚ	TypeErrorÚrangeÚ
ValueErrorÚformatÚ	__class__ÚPROPERTY_NAMEÚ__name__)Úselfr	   ÚendÚiÚes        úe/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/nltk/tbl/feature.pyÚ__init__zFeature.__init__#   s¹   € ðP ˆŒØˆ;Ü"¤6¸9Ö*E°a¬3¨q­6Ò*EÓ#FÓGˆD�Nð
Ø˜s’?Ü#�OÜ!&¤u¨Y¸¸a¹Ó'@Ó!A�”ð "Ÿ^™^×9Ñ9ÒT¸T¿^¹^×=TÑ=TˆÕùò +Føô ò ä ØH×OÑOØ! 3óóð ð	ûðús   ˜B¼(B Â	CÂ&CÃCc                 ó   — | j                   S ©N)r	   ©r   s    r   Úencode_json_objzFeature.encode_json_obj^   s   € Ø�~‰~Ðó    c                 ó   — |} | |«      S r   © )ÚclsÚobjr	   s      r   Údecode_json_objzFeature.decode_json_obja   s   € àˆ	Ù�9‹~Ðr   c                 ó`   — | j                   j                  › dt        | j                  «      ›d�S )Nú(ú))r   r   Úlistr	   r   s    r   Ú__repr__zFeature.__repr__f   s*   € Ø—.‘.×)Ñ)Ð*¨!¬D°·±Ó,@Ð+CÀ1ÐEÐEr   c                 óž   ‡— t        d„ |D «       «      st        d|› �«      ‚ˆfd„|D «       }|D �cg c]  }|rd|v rŒ
 | |«      ‘Œ c}S c c}w )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 kD  –— Œ y­w)r   Nr    )Ú.0Úxs     r   ú	<genexpr>z!Feature.expand.<locals>.<genexpr>Ÿ   s   è ø€ Ò*˜Q�1�q•5Ñ*ùs   ‚znon-positive window length in c              3   ól   •K  — | ]+  }t        t        ‰«      |z
  d z   «      D ]  }‰|||z    –— Œ Œ- y­w)r   N)r   Úlen)r+   Úwr   Ústartss      €r   r-   z!Feature.expand.<locals>.<genexpr>¡   s<   øè ø€ ÒU A¼%ÄÀFÃÈaÁÐRSÑ@SÓ:TÒU°Qˆf�Q˜˜Q™ÔÐUÐÑUùs   ƒ14r   )Úallr   )r!   r1   ÚwinlensÚexcludezeroÚxsr,   s    `    r   ÚexpandzFeature.expandi   sQ   ø€ ôl Ñ* 'Ô*Ô*ÜÐ=¸g¸YÐGÓHÐHÛU¨ÔUˆØ "ÖC˜1©;¸1Àº6‘�A•ÒCÐCùÒCs
   ±A
½
A
c                 óŒ   — | j                   |j                   u xr+ 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ÌCØ�O‰OóM
ñ 6
ð 	
r   c                 óž   — t        | j                  |j                  u xr+ 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   r8   r	   r9   s     r   Ú
intersectszFeature.intersectsÄ   s@   € ô: Ø�N‰N˜eŸo™oÐ-ò ;Ü�D—N‘NÓ#¤c¨%¯/©/Ó&:Ñ:ó
ð 	
r   c                 óh   — | j                   |j                   u xr | j                  |j                  k(  S r   )r   r	   r9   s     r   Ú__eq__zFeature.__eq__è   s'   € Ø�~‰~ §¡Ð0ÒV°T·^±^ÀuÇÁÑ5VÐVr   c                 ó’   — | j                   j                  |j                   j                  k  xs | j                  |j                  k  S r   )r   r   r	   r9   s     r   Ú__lt__zFeature.__lt__ë   s:   € à�N‰N×#Ñ# e§o¡o×&>Ñ&>Ñ>ò -ð �N‰N˜UŸ_™_Ñ,ð		
r   c                 ó   — | |k(   S r   r    r9   s     r   Ú__ne__zFeature.__ne__ó   s   € Ø˜E‘MÐ"Ð"r   c                 ó   — || k  S r   r    r9   s     r   Ú__gt__zFeature.__gt__ö   s   € Ø�t‰|Ðr   c                 ó   — | |k   S r   r    r9   s     r   Ú__ge__zFeature.__ge__ù   s   € Ø˜%‘<ÐÐr   c                 ó   — | |k  xs | |k(  S r   r    r9   s     r   Ú__le__zFeature.__le__ü   s   € Ø�e‰|Ò,˜t u™}Ð,r   c                  ó   — y)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(   r6   r;   r>   r@   rB   rD   rF   rH   rJ   Ústaticmethodr   rN   r    r   r   r   r      s—   „ ñð$ "€HØ€Mó9Uòvð ñó ðòFð ò8Dó ð8Dòt
ò@ 
òHWò
ò#òò ò-ð Øñ
ó ó ñ
r   r   )Ú	metaclassN)Úabcr   r   r   r    r   r   ú<module>rW      s   ð÷ (ô~˜ö ~r   