eta.schema.EpiSchema
- class EpiSchema(predicate='', participants=[], vars=[], bindings={}, header=[], contents=[], types=[], rigid_conds=[], static_conds=[], preconds=[], postconds=[], goals=[], episodes=[], episode_relations=[], necessities=[], certainties=[])[source]
Bases:
Schema
A schema representing a prototypical episode.
Sections
types : the nominal types of each participant/variable.
rigid-conds : non-fluent conditions relevant to episode.
static-conds : fluent conditions that are not expected to change during episode.
preconds : fluent conditions that are expected to hold at the beginning of episode.
postconds : fluent conditions that are expected to hold at end of episode.
goals : goals of participants in schema (e.g.,
(^me want.v (that ...))
).episodes : the expected/intended sub-episodes of the schema episode.
episode-relations : the temporal/causal relations between episodes of schema.
necessities : probabilities associated with schema formulas.
certainties : probabilities associated with schema episodes.
Methods
Bind the given variable symbol to the given value.
Bind variables in the schema header with a list of respective argument values.
Duplicate all variables across a schema, mapping the original variables to the duplicated ones.
Embed the schema based on the natural language representation of its contents, given an embedder object.
Format the contents of this schema as an S-expression string.
Get the schema contents as an S-expression.
Get the schema participants.
Get the eventualities within a given schema section or list of sections.
Get all episode symbols within a schema section or list of sections.
Get all wffs within a schema section or list of sections.
Instantiate a specific instance of a schema given a list of argument values for each variable in the header.
Read an S-expression containing schema contents (for a given predicate) into a dict of schema parameters.
Retrieve some number of facts from the schema according to similarity with a query string, given an embedder object.
Given a list of variable replacement mappings, apply the mappings to each part of the schema.
Given a list of certainty or necessity eventualities, create a probability dict with entries of form
{<ep>:<prob>}
.Unbind the given variable symbol.
- read_param_dict(schema_contents)[source]
Read an S-expression containing schema contents (for a given predicate) into a dict of schema parameters.
- __str__()
Return str(self).
- bind(var, val)
Bind the given variable symbol to the given value.
- bind_args(args)
Bind variables in the schema header with a list of respective argument values.
Generally, we assume that args should correspond to the variables in the participants list of the schema, but we allow for the possibility of ^me and ^you as implicit arguments if fewer arguments than variables are given - in which case, they’re added to the arguments list in that order.
On the other hand, if more arguments than variables are given, we assume that ^me and ^you might be provided as redundant arguments, and remove those from the front of the list if present. Otherwise, we remove superfluous arguments starting from the end of the list.
- Parameters:
args (list[s-expr]) – A list of expressions to bind to each respective header variable.
- duplicate_variables()
Duplicate all variables across a schema, mapping the original variables to the duplicated ones.
Note that this needs to be done in two steps to avoid mapping conflicts.
- embed(embedder)
Embed the schema based on the natural language representation of its contents, given an embedder object.
- format(no_bind=False)
Format the contents of this schema as an S-expression string.
- get_contents(no_bind=False)
Get the schema contents as an S-expression.
- Parameters:
no_bind (bool, default=False) – Do not make variable substitutions.
- Return type:
s-expr
- get_participants(no_bind=False)
Get the schema participants.
- get_section(sec)
Get the eventualities within a given schema section or list of sections.
- get_section_eps(sec, no_bind=False)
Get all episode symbols within a schema section or list of sections.
- get_section_wffs(sec, no_bind=False)
Get all wffs within a schema section or list of sections.
- instantiate(args)
Instantiate a specific instance of a schema given a list of argument values for each variable in the header.
This creates a deep copy of the schema, with duplicate variables to ensure that no collisions occur if the events in the schema are added to a plan.
- retrieve(embedder, query, n=5, header=True)
Retrieve some number of facts from the schema according to similarity with a query string, given an embedder object.
- Parameters:
- Returns:
The retrieved schema facts as S-expressions.
- Return type:
list[s-expr]
- subst_mappings(mappings)
Given a list of variable replacement mappings, apply the mappings to each part of the schema.
- to_probability_dict(eventualities, swap_duals=False)
Given a list of certainty or necessity eventualities, create a probability dict with entries of form
{<ep>:<prob>}
.If swap_duals is True, swap episode constants in the resulting probability dict with the dual var (e.g., ?e1 for !e1).
- unbind(var)
Unbind the given variable symbol.