diff --git a/CHANGELOG.md b/CHANGELOG.md index 899d4b1..fd0cd2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ Changelog ========= +v0.3.4 (2023-09-28) +------------------- +* Add `Serializable` class +* Make `BBox` child class of `Serializable` + v0.3.3 (2023-09-28) ------------------- * Update `BBox` class diff --git a/VERSION b/VERSION index 87a0871..448a0fa 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.3 \ No newline at end of file +0.3.4 \ No newline at end of file diff --git a/dedocutils/data_structures/bbox.py b/dedocutils/data_structures/bbox.py index bf69090..310de53 100644 --- a/dedocutils/data_structures/bbox.py +++ b/dedocutils/data_structures/bbox.py @@ -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. """ diff --git a/dedocutils/data_structures/serializable.py b/dedocutils/data_structures/serializable.py new file mode 100644 index 0000000..9de5d23 --- /dev/null +++ b/dedocutils/data_structures/serializable.py @@ -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