ó
    ´OÂfÏ$  ã                   ó&   • S SK JrJr   " S S\S9rg)é    )ÚABCMetaÚabstractmethodc                   ó¤   • \ rS rSrSrSrSrSS jrS r\	S 5       r
S r\	SS	 j5       rS
 rS rS rS rS rS rS rS r\\S 5       5       rSrg)ÚFeatureé   aÝ  
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           
      ó¤  • SU l         Uc4  [        [        U Vs1 s H  n[        U5      iM     sn5      5      U l         O( X:”  a  [        e[        [        XS-   5      5      U l         U R                  R                  =(       d    U R                  R                  U l	        gs  snf ! [         a   n[        SR                  X5      5      UeSnAff = f)a|  
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        Ú2/usr/lib/python3/dist-packages/nltk/tbl/feature.pyÚ__init__ÚFeature.__init__#   s·   € ðP ˆŒØ‰;Ü"¤6¹9Ó*Eº9°a¬3¨q®6¹9Ñ*EÓ#FÓGˆD�Nð
Ø“?Ü#�OÜ!&¤u¨Y¸a¹Ó'@Ó!A�”ð "Ÿ^™^×9Ñ9×T¸T¿^¹^×=TÑ=TˆÕùò +Føô ó ä ØH×OÑOØ!óóð ð	ûðús   ™B Á 'B% Â%
CÂ/C
Ã
Cc                 ó   • U R                   $ ©N)r
   ©r   s    r   Úencode_json_objÚFeature.encode_json_obj^   s   € Ø�~‰~Ðó    c                 ó   • UnU " U5      $ r   © )ÚclsÚobjr
   s      r   Údecode_json_objÚFeature.decode_json_obja   s   € àˆ	Ù�9‹~Ðr!   c                 ób   • U R                   R                   S[        U R                  5      < S3$ )NÚ(Ú))r   r   Úlistr
   r   s    r   Ú__repr__ÚFeature.__repr__f   s*   € Ø—.‘.×)Ñ)Ð*¨!¬D°·±Ó,@Ñ+CÀ1ÐEÐEr!   c                 ó¾   ^• [        S U 5       5      (       d  [        SU 35      eU4S jU 5       nU Vs/ s H  oS(       a  SU;   a  M  U " U5      PM     sn$ s  snf )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   ó*   #   • U  H	  oS :„  v •  M     g7f)r   Nr#   )Ú.0Úxs     r   Ú	<genexpr>Ú!Feature.expand.<locals>.<genexpr>Ÿ   s   é € Ð*¢'˜Q�q–5¢'ùs   ‚znon-positive window length in c              3   óv   >#   • U  H.  n[        [        T5      U-
  S -   5        H  nTX"U-    v •  M     M0     g7f)r	   N)r   Úlen)r0   Úwr   Ústartss      €r   r2   r3   ¡   s7   øé € ÐUª A¼%ÄÀFÃÈaÁÐRSÑ@S×:T°Qˆf�Q˜Q™ÕÑ:TÑªùs   ƒ69r   )Úallr   )r$   r7   ÚwinlensÚexcludezeroÚxsr1   s    `    r   ÚexpandÚFeature.expandi   sZ   ø€ ôl Ñ*¡'Ó*×*Ñ*ÜÐ=¸g¸YÐGÓHÐHÜU©ÓUˆÙ "ÓC¢˜1­;¸1À¹6“‘�A–¡ÑCÐCùÒCs   ·AÁAc                 ó–   • U R                   UR                   L =(       a+    [        U R                  5      [        UR                  5      :¬  $ )aÁ  
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   Ú
issupersetÚFeature.issuperset¤   s=   € ð8 �~‰~ §¡Ð0÷ 
´S¸¿¹Ó5HÌCØ�O‰OóM
ñ 6
ð 	
r!   c                 ó¨   • [        U R                  UR                  L =(       a+    [        U R                  5      [        UR                  5      -  5      $ )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   Ú
intersectsÚFeature.intersectsÄ   s@   € ô: Ø�N‰N˜eŸo™oÐ-÷ ;Ü�D—N‘NÓ#¤c¨%¯/©/Ó&:Ñ:ó
ð 	
r!   c                 ór   • U R                   UR                   L =(       a    U R                  UR                  :H  $ r   )r   r
   r@   s     r   Ú__eq__ÚFeature.__eq__è   s'   € Ø�~‰~ §¡Ð0×V°T·^±^ÀuÇÁÑ5VÐVr!   c                 óœ   • U R                   R                  UR                   R                  :  =(       d    U R                  UR                  :  $ r   )r   r   r
   r@   s     r   Ú__lt__ÚFeature.__lt__ë   s:   € à�N‰N×#Ñ# e§o¡o×&>Ñ&>Ñ>÷ -ð �N‰N˜UŸ_™_Ñ,ð		
r!   c                 ó   • X:X  + $ r   r#   r@   s     r   Ú__ne__ÚFeature.__ne__ó   s   € ØÒ"Ð"r!   c                 ó
   • X:  $ r   r#   r@   s     r   Ú__gt__ÚFeature.__gt__ö   s
   € Ø‰|Ðr!   c                 ó   • X:  + $ r   r#   r@   s     r   Ú__ge__ÚFeature.__ge__ù   s   € ØÒÐr!   c                 ó    • X:  =(       d    X:H  $ r   r#   r@   s     r   Ú__le__ÚFeature.__le__ü   s   € Ø‰|×,˜t™}Ð,r!   c                 ó   • g)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_propertyÚFeature.extract_propertyÿ   s   � r!   )r   r
   r   )F)r   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Újson_tagr   r   r   Úclassmethodr&   r,   r<   rB   rF   rI   rL   rO   rR   rU   rX   Ústaticmethodr   r]   Ú__static_attributes__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>ri      s   ð÷ (ô~˜ó ~r!   