eta.schema.SchemaLibrary
- class SchemaLibrary(embedder=None)[source]
Bases:
object
A library of all generic episode, dialogue, and object schemas.
- Parameters:
embedder (Embedder, optional) – If provided, an embedder to embed all schemas that are added.
- dial
A dict mapping dialogue schema predicates to dialogue schemas.
- Type:
Methods
Add a schema object to the library.
Create a schema object from the given predicate and contents (an S-expression) and add it to the library.
Recursively read schemas from all LISP files in a given directory or list of directories.
Read a set of schemas from a LISP file, storing them in the library.
Get all schemas of a particular type or list of types.
Check whether a given predicate exists in the schema library.
Retrieve some number of schemas of a particular type (or list of types).
Retrieve some number of facts from some number of retrieved schemas of a particular type (or list of types).
- create(predicate, contents)[source]
Create a schema object from the given predicate and contents (an S-expression) and add it to the library.
- is_schema(predicate, type=None)[source]
Check whether a given predicate exists in the schema library.
- retrieve(type, query=None, m=1)[source]
Retrieve some number of schemas of a particular type (or list of types).
- Parameters:
- Returns:
The retrieved schemas.
- Return type:
- retrieve_knowledge(type, query=None, m=1, n=5, header=True)[source]
Retrieve some number of facts from some number of retrieved schemas of a particular type (or list of types).
- Parameters:
type (str or list[str]) – A schema type (
dial
,epi
, orobj
), or a list of types.query (str, optional) – A query string to use to compute similarity. If not given, or if no embedder is defined, an arbitrary schema is retrieved.
m (int, default=1) – The number of schemas to retrieve.
n (int, default=5) – The number of facts to retrieve from each retrieved schema.
header (bool, default=True) – Whether to prefix the retrieved facts with the schema header.
- Returns:
The facts retrieved from each retrieved schema, as S-expressions.
- Return type:
list[s-expr]
- from_lisp_file(fname)[source]
Read a set of schemas from a LISP file, storing them in the library.
- Parameters:
fname (str) – The LISP file to read.