langtree.core.operator

Module Contents

Classes

Operator

A class to represent and process custom call and parse operations.

Functions

default_call(*args, **kwargs)

Default call function that returns the provided keyword arguments.

default_parse(output)

Default parse function that returns the provided output without modifications.

freeze(function, **top_kwargs)

Return a function with specific arguments frozen.

langtree.core.operator.default_call(*args, **kwargs)[source]

Default call function that returns the provided keyword arguments.

Parameters:
  • *args – Variable length argument list.

  • **kwargs – Arbitrary keyword arguments.

Returns:

The provided keyword arguments.

Return type:

dict

langtree.core.operator.default_parse(output)[source]

Default parse function that returns the provided output without modifications.

Parameters:

output – The output to parse.

Returns:

The unmodified output.

langtree.core.operator.freeze(function, **top_kwargs)[source]

Return a function with specific arguments frozen.

Parameters:
  • function (callable) – The function to freeze arguments for.

  • **top_kwargs – Keyword arguments to freeze.

Returns:

The function with specific arguments frozen.

Return type:

callable

class langtree.core.operator.Operator(call=default_call, parse=default_parse)[source]

Bases: object

A class to represent and process custom call and parse operations.

__call__(*args, **kwargs)[source]

Call the Operator’s call function and parse its result.

Parameters:
  • *args – Variable length argument list.

  • **kwargs – Arbitrary keyword arguments.

Returns:

The parsed result of the call function.

freeze_call(**kwargs)[source]

Freeze specific arguments for the Operator’s call function.

Parameters:

**kwargs – Keyword arguments to freeze.

freeze_parse(**kwargs)[source]

Freeze specific arguments for the Operator’s parse function.

Parameters:

**kwargs – Keyword arguments to freeze.