Skip to content

Commit

Permalink
add serializable
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Shevtsov committed Sep 28, 2023
1 parent dd85fc1 commit 8fc4aa0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion dedocutils/data_structures/bbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@

import numpy as np

from dedocutils.data_structures.serializable import Serializable


@dataclass
class BBox:
class BBox(Serializable):
"""
Bounding box around some page object, the coordinate system starts from top left corner.
"""
Expand Down
16 changes: 16 additions & 0 deletions dedocutils/data_structures/serializable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from abc import ABC, abstractmethod


class Serializable(ABC):
"""
Base class for the serializable objects which we need convert to dict.
"""
@abstractmethod
def to_dict(self) -> dict:
"""
Convert class data into dictionary representation.
Dictionary key should be string and dictionary value should be json serializable.
:return: dict with all class data.
"""
pass

0 comments on commit 8fc4aa0

Please sign in to comment.