U C^@@sLddlmZddlZddlZddlmZGdddeZddZd d Z dS) )unicode_literalsN)Errorsc@sdeZdZeeefZiZiZiZ dddZ ddZ ddZ dd Z d d Zd d ZddZddZdS) UnderscoreNcCsLt|d|t|d|t|d|jt|d|t|d|dS)N _extensions_obj_doc_start_end)object __setattr__doc)self extensionsobjstartendr:/tmp/pip-install-6_kvzl1k/spacy/spacy/tokens/underscore.py__init__s zUnderscore.__init__cCst|j}dddg|S)Nsetgethas)listrkeys)rrrrr__dir__szUnderscore.__dir__c Cs||jkrttjj|d|j|\}}}}|dk r@||jS|dk rrt||j}|jp^d}d}|||_|S| |} | |j j kr|j j | St ||j rt|} ||| | S|SdS)NnamezsThis method is a partial function and its first argument (the object it's called on) will be filled automatically. )rAttributeErrorrZE046formatr functoolspartial__doc___get_keyr user_data isinstance mutable_typescopyr ) rrdefaultmethodgettersetterZmethod_partialZmethod_docstringZmethod_docstring_prefixkeyZ new_defaultrrr __getattr__!s(          zUnderscore.__getattr__cCsX||jkrttjj|d|j|\}}}}|dk rB||j|S||jj||<dS)Nr) rrrZE047r rrr%r$)rrvaluer)r*r+r,rrrr =s   zUnderscore.__setattr__cCs |||SN)r )rrr/rrrrFszUnderscore.setcCs ||Sr0)r.rrrrrrIszUnderscore.getcCs ||jkSr0)rr1rrrrLszUnderscore.hascCsd||j|jfS)Nz._.)r r r1rrrr$OszUnderscore._get_key)NN)__name__ __module__ __qualname__dictrrr'Zdoc_extensionsZspan_extensionsZtoken_extensionsrrr.r rrr$rrrrr s   rcKs|d}|d}|d}|d}|dkrB|dk rBttjd|k|dk |dk f}tdd|D}|dkrttjj|d |dk rt|d sttjjdt |d |dk rt|d sttjjdt |d |dk rt|d sttjjdt |d ||||fS) z>Validate and convert arguments. Reused in Doc, Token and Span.r)r+r,r*Ncss|]}|dkVqdS)TNr).0trrr \szget_ext_args..) nr_defined__call__)rr/) r ValueErrorrZE089sumZE083r hasattrZE091repr)kwargsr)r+r,r*Z valid_optsr:rrr get_ext_argsSs"     rAcCs6|\}}}}|dk s.|dk s.tdd|Dr2dSdS)zCheck if an extension attribute is writable. ext (tuple): The (default, getter, setter, method) tuple available via {Doc,Span,Token}.get_extension. RETURNS (bool): Whether the attribute is writable. Ncss|]}|dkVqdSr0r)r6errrr8rsz#is_writable_attr..TF)all)extr)r*r+r,rrris_writable_attrhs "rE) __future__rr!r(errorsrr rrArErrrrs  I