schemacast.episode¶
Attributes¶
JsonScalar = str | int | float | bool | None
module-attribute
¶
KeyValue = str | int | float | bool
module-attribute
¶
MAX_KNOWN = 8
module-attribute
¶
Classes¶
ContextItem
¶
Bases: BaseModel
An earlier text in the same thread, shown for reference only.
Source code in schemacast/episode.py
Episode
¶
Bases: BaseModel
One text to cast.
The structured half of a record — author, channel, thread — belongs in
metadata and is written by an ordinary GraFlo resource, never read off
the text by the model; metadata is not shown to the model.
Source code in schemacast/episode.py
Attributes¶
context = Field(default_factory=list, description='Preceding texts in the thread, for resolving references only.')
class-attribute
instance-attribute
¶
known = Field(default_factory=list, description=f'Entities the source names, at most {MAX_KNOWN}; an edge the text states may end at one.')
class-attribute
instance-attribute
¶
metadata = Field(default_factory=dict, description='Source metadata, never shown to the model.')
class-attribute
instance-attribute
¶
model_config = ConfigDict(extra='forbid')
class-attribute
instance-attribute
¶
reference_time = Field(default=None, description='When the text was written; resolves relative dates.')
class-attribute
instance-attribute
¶
source_id = Field(min_length=1, description='Stable identifier of the source record.')
class-attribute
instance-attribute
¶
text = Field(min_length=1, description='The text to cast.')
class-attribute
instance-attribute
¶
EpisodeFileError
¶
KnownEntity
¶
Bases: BaseModel
An entity the text belongs to or is about, identified by its source.
The model may relate to it by ref but never adds it as a vertex or states its properties: its identity comes from the source, never from the text.
Source code in schemacast/episode.py
Attributes¶
key = Field(min_length=1, description='Its primary identity: every identity field of the type and nothing else, or it is not shown.')
class-attribute
instance-attribute
¶
label = Field(default=None, description='A name shown to the model.')
class-attribute
instance-attribute
¶
model_config = ConfigDict(extra='forbid')
class-attribute
instance-attribute
¶
role = Field(pattern='^[a-z][a-z_]*$', description='What it is to the text, e.g. ``subject``: the record the text belongs to.')
class-attribute
instance-attribute
¶
vertex_type = Field(min_length=1, description='Its vertex type.')
class-attribute
instance-attribute
¶
Functions:¶
read_episodes(path)
¶
Read episodes from a JSON Lines file, one object per line.
Blank lines are skipped.
Raises:
| Type | Description |
|---|---|
EpisodeFileError
|
on the first line that is not a valid episode. |