concepts.language.neural_ccg.grammar.NeuralCCGGroundingFunction#

class NeuralCCGGroundingFunction[source]#

Bases: object

A data structure contains the implementation of a function (for neural CCG semantics).

Methods

bind_constants(constant)

Bind a constant to the function.

Attributes

expression

The function application expression, the function, or a python Callable function representing the semantic form of the function.

executor

The executor for the domain.

nr_arguments

The number of arguments to the function.

constant_arg_types

The types of the constant arguments.

bound_constant

The constant that is bound to the function.

note

The note for the function.

__call__(*args)[source]#

Execute the function with the given arguments.

Parameters:

*args (Callable | Value) – the arguments to the function.

Returns:

the result of the function.

Return type:

Value

__init__(expression, executor, nr_arguments=None, constant_arg_types=None, bound_constant=None, note='<anonymous>')[source]#

Initialize a neural CCG function.

Parameters:
  • expression (Callable | ConstantExpression | Function | FunctionApplicationExpression) – the function application expression, the function, or a python Callable function representing the semantic form of the function.

  • executor (FunctionDomainExecutor) – the executor for the domain.

  • nr_arguments (int | None) – the number of arguments to the function.

  • constant_arg_types (Iterable[ConstantType] | None) – the types of the constant arguments. Note that constant-typed arguments always come last.

  • bound_constant (str | None) – the constant that is bound to the function. During execution, constant-typed arguments will be filled with this constant.

  • note (Any) – the note for the function. This is used for debugging.

__new__(**kwargs)#
bind_constants(constant)[source]#

Bind a constant to the function. This function derives a new function with the same underlying expression.

Parameters:

constant (str) – the constant to be bound.

Returns:

the new function with the constant bound.

Return type:

NeuralCCGGroundingFunction

bound_constant: str | None#

The constant that is bound to the function. During execution, constant-typed arguments will be filled with this constant.

constant_arg_types: Tuple[ConstantType]#

The types of the constant arguments. Note that constant-typed arguments always come last.

executor: FunctionDomainExecutor#

The executor for the domain.

expression: Callable | Function | FunctionApplicationExpression#

The function application expression, the function, or a python Callable function representing the semantic form of the function.

note: Any#

The note for the function. This is used for debugging.

nr_arguments: int#

The number of arguments to the function.