ó <¿CVc@suddlmZddlmZmZddlmZdefd„ƒYZeej defd„ƒYƒƒZ dS( iÿÿÿÿ(tprint_function(tpython_2_unicode_compatiblet unicode_repr(tjsontagstTagRulecBsGeZdZd„Zdd„Zd„Zd„Zd„Zd„Z RS(s An interface for tag transformations on a tagged corpus, as performed by tbl taggers. Each transformation finds all tokens in the corpus that are tagged with a specific original tag and satisfy a specific condition, and replaces their tags with a replacement tag. For any given transformation, the original tag, replacement tag, and condition are fixed. Conditions may depend on the token under consideration, as well as any other tokens in the corpus. Tag rules must be comparable and hashable. cCs||_||_dS(N(t original_tagtreplacement_tag(tselfRR((s_/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/tbl/rule.pyt__init__#s  cCs‚|dkr'ttt|ƒƒƒ}ng|D]}|j||ƒr.|^q.}x)|D]!}||d|jf||Ós( t _Rule__reprR/R2R-RRRRRtjoinR(R((s_/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/tbl/rule.pyt__repr__Äs     "cCs\d„}djg|jD]\}}|||ƒ^qƒ}dj|j|j|ƒ}|S(NcSs,dj|j|djd„|jDƒƒƒS(s| Return a compact, predicate-logic styled string representation of the given condition. s {0}:{1}@[{2}]t,css|]}t|ƒVqdS(N(tstr(R3tw((s_/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/tbl/rule.pys âs(R2t PROPERTY_NAMER7R(R*tvalue((s_/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/tbl/rule.pyt_condition_to_logicÚss & s{0}->{1} if {2}(R7RR2RR(RR>R4R5R ts((s_/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/tbl/rule.pyt__str__Ùs 4 cCs[|dkr|jƒS|dkr,|jƒS|dkrB|jƒStdj|ƒƒ‚dS(sã Return a string representation of this rule. >>> from nltk.tbl.rule import Rule >>> from nltk.tag.brill import Pos >>> r = Rule("23", "VB", "NN", [(Pos([-2,-1]), 'DT')]) r.format("str") == str(r) True >>> r.format("str") 'VB->NN if Pos:DT@[-2,-1]' r.format("repr") == repr(r) True >>> r.format("repr") "Rule('23', 'VB', 'NN', [(Pos([-2, -1]),'DT')])" >>> r.format("verbose") 'VB -> NN if the Pos of words i-2...i-1 is "DT"' >>> r.format("not_found") Traceback (most recent call last): File "", line 1, in File "nltk/tbl/rule.py", line 256, in format raise ValueError("unknown rule format spec: {0}".format(fmt)) ValueError: unknown rule format spec: not_found >>> :param fmt: format specification :type fmt: str :return: string representation :rtype: str R:R1tverbosesunknown rule format spec: {0}N(R@R8t_verbose_formatt ValueErrorR2(Rtfmt((s_/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/tbl/rule.pyR2îs#      csk‡fd†‰d„‰d|j|jf}|jr=dnddj‡fd†|jDƒƒ}||S(s‡ Return a wordy, human-readable string representation of the given rule. Not sure how useful this is. csd|jˆ|jƒ|fS(Nsthe %s of %s is "%s"(R<R(R*R=(t range_to_str(s_/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/tbl/rule.pytcondition_to_str!scSsÚt|ƒdkrx|d}|dkr,dS|dkr<dS|dkrLdS|dkrad| S|dkrÖd|Sn^t|ƒ}t|ƒ}||t|ƒdkr¸d ||fSd d jd „|DƒƒfSdS( Niis this wordiÿÿÿÿsthe preceding wordsthe following words word i-%ds word i+%dswords i%+d...i%+ds words {%s}R9css|]}d|VqdS(si%+dN((R3td((s_/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/tbl/rule.pys 9s(R tmaxtminR7(Rtptmxtmn((s_/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/tbl/rule.pyRE%s"          s%s -> %ss if ts, and c3s$|]\}}ˆ||ƒVqdS(N((R3R4R5(RF(s_/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/tbl/rule.pys =s(RRRR7(RR"R ((RFREs_/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/tbl/rule.pyRBs  (RRRtjson_tagRR#t classmethodR&R RRRR8R@R2RB(((s_/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/tbl/rule.pyRas        ,N( t __future__Rt nltk.compatRRtnltkRtobjectRt register_tagR(((s_/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/tbl/rule.pyt s L