eta.transducers.tt.TTTransducer

class TTTransducer(rule_dirs, roots)[source]

Bases: Transducer

The abstract TT transducer class containing the core implementation of the TT mapping process.

Each TT transducer is initialized with a set of trees and word features read from a directory of LISP choice tree packets, as well as a list of root names to use specific to that particular transducer.

The transducer performs a mapping by passing its arguments (or some data derived from the arguments) to its root choice tree(s), processing the results based on the directive, and combining them into a single flat list.

Parameters:
  • rule_dirs (str or list[str]) – The directory name(s) containing LISP choice tree packets to read from.

  • roots (str or list[str]) – The root name(s) to use for choosing results for this transducer instance.

trees

A dict mapping choice tree root names to the choice tree roots.

Type:

dict

feats

A dict mapping words to feature lists.

Type:

dict

roots

A list of root names to use for choosing results.

Type:

list[str]

Methods

cost

TT is performed locally so does not incur any cost.

__call__(inputs)[source]

Choose a result for some input using TT.

Parameters:

inputs (str or list[str] or s-expr) – The input or inputs to use for choosing a result. If the input is a string or list of strings (where none of the strings are quoted expressions), it is used to create a single word list after concatenating each substring. Otherwise, the input is an S-expression and is used directly as input.

Returns:

A list of chosen results (which may be processed further by the specific transducer instance).

Return type:

list[str or s-expr]

cost()[source]

TT is performed locally so does not incur any cost.