cognition.knowledge.representation¶
Knowledge representation
Attributes¶
Graphical representation of concepts and relationships |
Classes¶
Produces an immutable version |
|
Produces a mutable version |
|
Freezable base model with a fixed set of required (immutable) fields. |
|
Distinct object, concept, or event |
|
A relationship between two entities |
Module Contents¶
- class cognition.knowledge.representation.Freezable¶
Bases:
ProtocolProduces an immutable version
- freeze()¶
- Returns:
immutable version
- Return type:
Self
- class cognition.knowledge.representation.Thawable[T]¶
Bases:
ProtocolProduces a mutable version
- thaw()¶
- Returns:
mutable version
- Return type:
T
- class cognition.knowledge.representation.BaseSchema¶
Bases:
cognition.util.misc.TypedMixin,pydantic.BaseModel,abc.ABCFreezable base model with a fixed set of required (immutable) fields.
As necessary, provides support to freeze custom fields via (a) automatic detection of list->tuple, set->frozenset; or (b) recursive freezing via
Freezable; or (c) subtype implementations of freeze_fieldname method.Frozen instance is a subtype that is then thawable to produce a copy of the original instance.
- classmethod fixed_field_names()¶
- Abstractmethod:
- Returns:
frozen required field names
- Return type:
tuple[str, Ellipsis]
- property custom_fields: collections.abc.Iterable[tuple[str, Any]]¶
Non-fixed fields
- Returns:
name/value pairs for non-required fields, if any
- Return type:
collections.abc.Iterable[tuple[str, Any]]
- __str__()¶
KR representation
- Returns:
e.type(fixed1=’e.fixed1’[, …][, custom1=e.custom1, …])
- Return type:
str
- replace(**fields)¶
Produces a copy with optional field changes
- Parameters:
fields (Any) – name=new value
- Returns:
copy
- Raises:
KeyError – invalid (non-required) field
ValidationError – violates schema
- Return type:
Self
- classmethod __pydantic_init_subclass__(**kwargs)¶
- Parameters:
kwargs (Any)
- Return type:
None
- CUSTOM_FREEZE_METHOD: ClassVar[string.Template]¶
field name (via
fieldparameter)-> custom freeze method name
- class cognition.knowledge.representation.Entity¶
Bases:
BaseSchemaDistinct object, concept, or event that is named
- name: str¶
- classmethod fixed_field_names()¶
- Returns:
frozen required field names
- Return type:
tuple[str, Ellipsis]
- class cognition.knowledge.representation.BinaryRelation¶
Bases:
BaseSchemaA relationship between two entities
- classmethod fixed_field_names()¶
- Returns:
frozen required field names
- Return type:
tuple[str, Ellipsis]
- type cognition.knowledge.representation.Fact = Entity | BinaryRelation¶
Graphical representation of concepts and relationships