nltk.ccg.combinator module

CCG Combinators

class nltk.ccg.combinator.BackwardCombinator[source]

Bases: DirectedBinaryCombinator

The backward equivalent of the ForwardCombinator class.

__init__(combinator, predicate, suffix='')[source]
can_combine(left, right)[source]
combine(left, right)[source]
class nltk.ccg.combinator.DirectedBinaryCombinator[source]

Bases: object

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.

abstract can_combine(left, right)[source]
abstract combine(left, right)[source]
class nltk.ccg.combinator.ForwardCombinator[source]

Bases: DirectedBinaryCombinator

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.

__init__(combinator, predicate, suffix='')[source]
can_combine(left, right)[source]
combine(left, right)[source]
class nltk.ccg.combinator.UndirectedBinaryCombinator[source]

Bases: object

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.

abstract can_combine(function, argument)[source]
abstract combine(function, argument)[source]
class nltk.ccg.combinator.UndirectedComposition[source]

Bases: UndirectedBinaryCombinator

Functional composition (harmonic) combinator. Implements rules of the form X/Y Y/Z -> X/Z (B>) And the corresponding backwards and crossed variations.

can_combine(function, argument)[source]
combine(function, argument)[source]
class nltk.ccg.combinator.UndirectedFunctionApplication[source]

Bases: UndirectedBinaryCombinator

Class representing function application. Implements rules of the form: X/Y Y -> X (>) And the corresponding backwards application rule

can_combine(function, argument)[source]
combine(function, argument)[source]
class nltk.ccg.combinator.UndirectedSubstitution[source]

Bases: UndirectedBinaryCombinator

Substitution (permutation) combinator. Implements rules of the form Y/Z (XY)/Z -> X/Z (<Sx) And other variations.

can_combine(function, argument)[source]
combine(function, argument)[source]
class nltk.ccg.combinator.UndirectedTypeRaise[source]

Bases: UndirectedBinaryCombinator

Undirected combinator for type raising.

can_combine(function, arg)[source]
combine(function, arg)[source]
nltk.ccg.combinator.backwardBxConstraint(left, right)[source]
nltk.ccg.combinator.backwardOnly(left, right)[source]
nltk.ccg.combinator.backwardSxConstraint(left, right)[source]
nltk.ccg.combinator.backwardTConstraint(left, right)[source]
nltk.ccg.combinator.bothBackward(left, right)[source]
nltk.ccg.combinator.bothForward(left, right)[source]
nltk.ccg.combinator.crossedDirs(left, right)[source]
nltk.ccg.combinator.forwardOnly(left, right)[source]
nltk.ccg.combinator.forwardSConstraint(left, right)[source]
nltk.ccg.combinator.forwardTConstraint(left, right)[source]
nltk.ccg.combinator.innermostFunction(categ)[source]