ó <¿CVc@sdZddlmZddlmZddlmZdefd„ƒYZdefd„ƒYZ ed e fd „ƒYƒZ ed e fd „ƒYƒZ ed efd„ƒYƒZ d„Z d„Ze e ƒe ƒZe e ƒeƒZedefd„ƒYƒZd„Zd„Zd„Zd„Ze eƒe ƒZe eƒeƒZe eƒeddƒZedefd„ƒYƒZd„Zd„Ze eƒeƒZe eƒedƒZd„Zedefd„ƒYƒZd „Z d!„Z!e eƒe ƒZ"e eƒe!ƒZ#d"S(#u CCG Combinators iÿÿÿÿ(tunicode_literals(tpython_2_unicode_compatible(tFunctionalCategorytUndirectedBinaryCombinatorcBs eZdZd„Zd„ZRS(u« Abstract class for representing a binary combinator. Merely defines functions for checking if the function and argument are able to be combined, and what the resulting category is. Note that as no assumptions are made as to direction, the unrestricted combinators can perform all backward, forward and crossed variations of the combinators; these restrictions must be added in the rule class. cCs tƒ‚dS(N(tNotImplementedError(tselftfunctiontargument((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyt can_combinescCs tƒ‚dS(N(R(RRR((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pytcombines(t__name__t __module__t__doc__RR (((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyRs  tDirectedBinaryCombinatorcBs eZdZd„Zd„ZRS(uÝ Wrapper for the undirected binary combinator. It takes left and right categories, and decides which is to be the function, and which the argument. It then decides whether or not they can be combined. cCs tƒ‚dS(N(R(Rtlefttright((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyR(scCs tƒ‚dS(N(R(RRR((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyR +s(R R R RR (((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyR !s tForwardCombinatorcBs5eZdZdd„Zd„Zd„Zd„ZRS(uÏ Class representing combinators where the primary functor is on the left. Takes an undirected combinator, and a predicate which adds constraints restricting the cases in which it may apply. ucCs||_||_||_dS(N(t _combinatort _predicatet_suffix(Rt combinatort predicatetsuffix((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyt__init__6s  cCs%|jj||ƒo$|j||ƒS(N(RRR(RRR((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyR;sccs)x"|jj||ƒD] }|VqWdS(N(RR (RRRtcat((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyR ?scCsd|j|jfS(Nu>%s%s(RR(R((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyt__str__Cs(R R R RRR R(((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyR.s    tBackwardCombinatorcBs5eZdZdd„Zd„Zd„Zd„ZRS(uA The backward equivalent of the ForwardCombinator class. ucCs||_||_||_dS(N(RRR(RRRR((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyRKs  cCs%|jj||ƒo$|j||ƒS(N(RRR(RRR((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyRPsccs)x"|jj||ƒD] }|VqWdS(N(RR (RRRR((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyR SscCsd|j|jfS(Nu<%s%s(RR(R((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyRWs(R R R RRR R(((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyRFs    tUndirectedFunctionApplicationcBs)eZdZd„Zd„Zd„ZRS(uœ Class representing function application. Implements rules of the form: X/Y Y -> X (>) And the corresponding backwards application rule cCs)|jƒstS|jƒj|ƒdk S(N(t is_functiontFalsetargt can_unifytNone(RRR((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyRcs ccsM|jƒsdS|jƒj|ƒ}|dkr5dS|jƒj|ƒVdS(N(RRRR trest substitute(RRRtsubs((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyR is   cCsdS(Nu((R((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyRss(R R R RR R(((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyRZs  cCs|jƒjƒS(N(tdirt is_forward(RR((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyt forwardOnlyzscCs|jƒjƒS(N(R$t is_backward(RR((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyt backwardOnly~stUndirectedCompositioncBs)eZdZd„Zd„Zd„ZRS(u¬ Functional composition (harmonic) combinator. Implements rules of the form X/Y Y/Z -> X/Z (B>) And the corresponding backwards and crossed variations. cCsc|jƒo|jƒstS|jƒjƒr_|jƒjƒr_|jƒj|jƒƒdk StS(N(RRR$t can_composeRRR!R (RRR((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyRs $ccs¦|jƒo|jƒsdS|jƒjƒr¢|jƒjƒr¢|jƒj|jƒƒ}|dk r¢t|jƒj|ƒ|jƒj|ƒ|jƒƒVq¢ndS(N( RR$R*RRR!R RR"(RRRR#((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyR ™s$ cCsdS(NuB((R((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyR¢s(R R R RR R(((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyR)ˆs cCs"|jƒjƒo!|jƒjƒS(N(R$R%(RR((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyt bothForward¦scCs"|jƒjƒo!|jƒjƒS(N(R$R'(RR((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyt bothBackward©scCs"|jƒjƒo!|jƒjƒS(N(R$R%R'(RR((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyt crossedDirs®scCsLt||ƒstS|jƒjƒ r<|jƒjƒr<tS|jƒjƒS(N(R-RR$t can_crossRt is_primitive(RR((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pytbackwardBxConstraint±s %RuxtUndirectedSubstitutioncBs)eZdZd„Zd„Zd„ZRS(uˆ Substitution (permutation) combinator. Implements rules of the form Y/Z (X\Y)/Z -> X/Z (t|jƒjƒ|jƒ|jƒƒVndS(N(RRR!RR$(RRR((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyR ÜscCsdS(NuS((R((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyRàs(R R R RR R(((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyR1Ås  cCs;t||ƒstS|jƒjƒjƒo:|jƒjƒS(N(R+RR!R$R%RR/(RR((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pytforwardSConstraintäscCsd|jƒjƒ r)|jƒjƒr)tSt||ƒs<tS|jƒjƒjƒoc|jƒjƒS(N(R$R.RR+R!R'RR/(RR((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pytbackwardSxConstraintês %cCs)x"|jƒjƒr$|jƒ}qW|S(N(R!R(tcateg((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pytinnermostFunctionústUndirectedTypeRaisecBs)eZdZd„Zd„Zd„ZRS(u1 Undirected combinator for type raising. cCsW|jƒo|jƒjƒs"tSt|ƒ}tjtjƒƒ}|dk rSt StS(N( RR!RR5RRt arg_categRR tTrue(RRRR#((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyRs  ccs¡|jƒo'|jƒo'|jƒjƒs.dSt|ƒ}|j|jƒƒ}|dk r|jƒj|ƒ}t|t|||j ƒƒ|j ƒ ƒVndS(N( R/RR!R5RRR R"RR$(RRRR#txcat((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyR s   cCsdS(NuT((R((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyR&s(R R R RR R(((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyR6ÿs  cCs.t|ƒ}|jƒjƒo-|jƒjƒS(N(R5R$R'R!R/(RRR((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pytforwardTConstraint.s cCs.t|ƒ}|jƒjƒo-|jƒjƒS(N(R5R$R%R!R/(RRR((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pytbackwardTConstraint2s N($R t __future__Rt nltk.compatRt nltk.ccg.apiRtobjectRR RRRR&R(tForwardApplicationtBackwardApplicationR)R+R,R-R0tForwardCompositiontBackwardCompositiont BackwardBxR1R2R3tForwardSubstitutiont BackwardSxR5R6R:R;tForwardTt BackwardT(((se/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/ccg/combinator.pyt sX                      .