This commit is contained in:
+24
-3
@@ -8,9 +8,15 @@ SHAPES = ("circle", "square", "triangle", "star")
|
||||
RELATIONS = ("left_of", "right_of", "above", "below")
|
||||
CLASSES = ("alpha", "beta", "gamma", "delta")
|
||||
OBJECT_IDS = ("obj1", "obj2", "obj3")
|
||||
VARIABLES = ("var_x",)
|
||||
|
||||
PREDICATES = ("color", "shape", "left_of", "right_of", "above", "below", "implies_class")
|
||||
ENTITIES = OBJECT_IDS + COLORS + SHAPES + CLASSES
|
||||
PREDICATES = ("color", "shape", "left_of", "right_of", "above", "below", "class")
|
||||
ENTITIES = OBJECT_IDS + COLORS + SHAPES + CLASSES + VARIABLES
|
||||
|
||||
NULL_TYPE = 0
|
||||
FACT_TYPE = 1
|
||||
RULE_TYPE = 2
|
||||
NUM_STATE_TYPES = 3
|
||||
|
||||
SUBJECT_TO_ID = {value: index for index, value in enumerate(ENTITIES)}
|
||||
PREDICATE_TO_ID = {value: index for index, value in enumerate(PREDICATES)}
|
||||
@@ -31,6 +37,22 @@ class Fact:
|
||||
return cls(**value)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Rule:
|
||||
variable: str
|
||||
antecedent_predicate: str
|
||||
antecedent_object: str
|
||||
consequent_predicate: str
|
||||
consequent_object: str
|
||||
|
||||
def to_dict(self) -> dict[str, str]:
|
||||
return asdict(self)
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, value: dict[str, str]) -> "Rule":
|
||||
return cls(**value)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class SceneObject:
|
||||
object_id: str
|
||||
@@ -41,4 +63,3 @@ class SceneObject:
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
return asdict(self)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user