eta.schema.ObjSchema

class ObjSchema(predicate='', participants=[], vars=[], bindings={}, header=[], contents=[], types=[], rigid_conds=[], skeletal_prototype='', purposes=[], necessities=[])[source]

Bases: Schema

A schema representing a prototypical object.

Sections

  • types : the nominal types of each participant/variable.

  • rigid-conds : non-fluent conditions relevant to object.

  • skeletal-prototype : 3D mesh decomposition of object (.obj filenames).

  • purposes : telic purpose associated with object.

  • necessities : probabilities associated with schema formulas.

Methods

bind

Bind the given variable symbol to the given value.

bind_args

Bind variables in the schema header with a list of respective argument values.

duplicate_variables

Duplicate all variables across a schema, mapping the original variables to the duplicated ones.

embed

Embed the schema based on the natural language representation of its contents, given an embedder object.

format

Format the contents of this schema as an S-expression string.

get_contents

Get the schema contents as an S-expression.

get_participants

Get the schema participants.

get_section

Get the eventualities within a given schema section or list of sections.

get_section_eps

Get all episode symbols within a schema section or list of sections.

get_section_wffs

Get all wffs within a schema section or list of sections.

instantiate

Instantiate a specific instance of a schema given a list of argument values for each variable in the header.

read_param_dict

Read an S-expression containing schema contents (for a given predicate) into a dict of schema parameters.

retrieve

Retrieve some number of facts from the schema according to similarity with a query string, given an embedder object.

subst_mappings

Given a list of variable replacement mappings, apply the mappings to each part of the schema.

to_probability_dict

Given a list of certainty or necessity eventualities, create a probability dict with entries of form {<ep>:<prob>}.

unbind

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.

Parameters:

no_bind (bool, default=False) – Do not make variable substitutions.

Return type:

list[s-expr]

get_section(sec)

Get the eventualities within a given schema section or list of sections.

Parameters:

sec (str or list[str]) – A section label or list of section labels, or the keyword :all to return all sections.

Return type:

list[Eventuality]

get_section_eps(sec, no_bind=False)

Get all episode symbols within a schema section or list of sections.

Parameters:
  • sec (str or list[str]) – A section label or list of section labels, or the keyword :all to return all sections.

  • no_bind (bool, default=False) – Do not make variable substitutions.

Return type:

list[str]

get_section_wffs(sec, no_bind=False)

Get all wffs within a schema section or list of sections.

Parameters:
  • sec (str or list[str]) – A section label or list of section labels, or the keyword :all to return all sections.

  • no_bind (bool, default=False) – Do not make variable substitutions.

Return type:

list[s-expr]

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.

Parameters:

args (list[s-expr]) – A list of expressions to bind to each respective header variable.

Return type:

Schema

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:
  • embedder (Embedder) – An Embedder object.

  • query (str) – A query string to use to compute similarity.

  • n (int, default=5) – The number of facts to retrieve.

  • header (bool, default=True) – Whether to prefix the retrieved facts with the schema header.

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.