Changes in embedding.py, phrase.py, symbol.py, word.py

Added from_dict class methods
This commit is contained in:
Christoph Eder committed 2025-12-12 17:23:32 +01:00
1 parent ac2bb3ce29
commit 7126a66331
4 files changed
+45 -13

No files matched your search

+8
View File
@@ -12,6 +12,14 @@ class Symbol:
label: str
image: Tensor[np.ndarray[Any, Any], tuple, Literal["int32", "int64"]]
@classmethod
def from_dict(cls, data: dict) -> 'Symbol':
return cls(
id=data['id'],
label=data['label'],
image=np.array(data['image'], dtype=np.int32)
)
@classmethod
def __get_pydantic_core_schema__(cls, source_type: Any, handler):
from pydantic_core import core_schema