+
    ÖÇÜhÏ$  ã                   ó.   € ^ RI HtHt  ! R R]R7      tR# )é    )ÚABCMetaÚabstractmethodc                   ó°   a € ] tR t^t o RtRtRtRR ltR t]	R 4       t
R t]	RR l4       tR	 tR
 tR tR tR tR tR tR t]]R 4       4       tRtV tR# )Ú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           
     ó´  € RV n         Vf4   \        \        V Uu0 uF  p\        V4      kK  	  up4      4      V n         M- W8”  d   \        h\        \        W^,           4      4      V n         V P                  P                  ;'       g    V P                  P                  V n	        R# u upi   \         d!   p\        RP                  Y4      4      ThRp?ii ; i)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
Nz2illegal 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Ñ=TˆÖùò +Føô ô ä ØH×OÑOØ!óóð ð	ûðús   šB'Á ,B, Â,CÂ7CÃCc                ó   € V P                   # ©N)r   ©r   s   &r   Úencode_json_objÚFeature.encode_json_obj^   s   € Ø�~‰~Ðó    c                ó   € TpV ! V4      # r   © )ÚclsÚobjr   s   && r   Údecode_json_objÚFeature.decode_json_obja   s   € àˆ	Ù�9‹~Ðr   c                ób   € V P                   P                   R \        V P                  4      : R2# )Ú(Ú))r   r   Úlistr   r   s   &r   Ú__repr__ÚFeature.__repr__f   s*   € Ø—.‘.×)Ñ)Ð*¨!¬D°·±Ó,@Ñ+CÀ1ÐEÐEr   c                ó  a€ \         ;QJ d    R V 4       F  '       d   K   RM	  RM! R V 4       4      '       g   \        RV 24      hV3R lV 4       pV Uu. uF  qS'       d
   ^ V9   d   K  V ! V4      NK  	  up# u upi )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   ó*   "  € T F	  q^ 8„  x € K  	  R# 5i)r   Nr!   )Ú.0Úxs   & r   Ú	<genexpr>Ú!Feature.expand.<locals>.<genexpr>Ÿ   s   é € Ð*¡'˜Q�q–5£'ùs   ‚FTznon-positive window length in c              3   óŒ   <"  € T F9  p\        \        S4      V,
          ^,           4       F  pSW"V,            x € K  	  K;  	  R# 5i)é   N)r   Úlen)r.   Úwr   Ústartss   &  €r   r0   r1   ¡   s7   øé € ÐU© A¼%ÄÀFÃÈaÅÐRSÕ@SÖ:T°Qˆf�Q˜Q�ÕÑ:TÑ«ùs   ƒAA)Úallr   )r"   r6   ÚwinlensÚexcludezeroÚxsr/   s   &f&&  r   ÚexpandÚFeature.expandi   sj   ø€ ÷l ‹sÑ*¡'Ó*�s�sŠsÑ*¡'Ó*×*Ò*ÜÐ=¸g¸YÐGÓHÐHÜU©ÓUˆÙ "ÓC¡˜1®;¸1À¹6”‘�A–¡ÑCÐCùÒCs   ÁA>Á/A>c                ó˜   € V P                   VP                   J ;'       d,    \        V P                  4      \        VP                  4      8¬  # )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¤   sB   € ð8 �~‰~ §¡Ð0÷ 
ð 
´S¸¿¹Ó5HÌCØ�O‰OóM
ñ 6
ð 	
r   c                ó²   € \        V P                  VP                  J ;'       d0    \        V P                  4      \        VP                  4      ,          4      # )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Ä   sE   € ô: Ø�N‰N˜eŸo™oÐ-÷ ;ð ;Ü�D—N‘NÓ#¤c¨%¯/©/Ó&:Õ:ó
ð 	
r   c                ót   € V P                   VP                   J ;'       d    V P                  VP                  8H  # r   )r   r   r?   s   &&r   Ú__eq__ÚFeature.__eq__è   s*   € Ø�~‰~ §¡Ð0×VÐV°T·^±^ÀuÇÁÑ5VÐVr   c                óž   € V P                   P                  VP                   P                  8  ;'       g    V P                  VP                  8  # r   )r   r   r   r?   s   &&r   Ú__lt__ÚFeature.__lt__ë   s?   € à�N‰N×#Ñ# e§o¡o×&>Ñ&>Ñ>÷ -ð -ð �N‰N˜UŸ_™_Ñ,ð		
r   c                ó   € W8X  * # r   r!   r?   s   &&r   Ú__ne__ÚFeature.__ne__ó   s   € ØÒ"Ð"r   c                ó
   € W8  # r   r!   r?   s   &&r   Ú__gt__ÚFeature.__gt__ö   s
   € Ø‰|Ðr   c                ó   € W8  * # r   r!   r?   s   &&r   Ú__ge__ÚFeature.__ge__ù   s   € ØÒÐr   c                ó"   € W8  ;'       g    W8H  # r   r!   r?   s   &&r   Ú__le__ÚFeature.__le__ü   s   € Ø‰|×,Ð,˜t™}Ð,r   c                ó   € R# )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;   rA   rE   rH   rK   rN   rQ   rT   rW   Ústaticmethodr   r\   Ú__static_attributes__Ú__classdictcell__)Ú__classdict__s   @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>rj      s   ð÷ (ô~˜÷ ~r   