Skip to content

Commit

Permalink
Turn captions into list field
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Auer <[email protected]>
  • Loading branch information
cau-git committed Sep 23, 2024
1 parent 0685709 commit 425858a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions docling_core/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@
from docling_core.types.doc.document import ExportedCCSDocument as Document # noqa
from docling_core.types.gen.generic import Generic # noqa
from docling_core.types.rec.record import Record # noqa

from docling_core.types.experimental.document import DoclingDocument
6 changes: 3 additions & 3 deletions docling_core/types/experimental/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def from_dict_format(cls, data: Any) -> Any:


class BaseTableData(BaseModel): # TBD
table_cells: List[TableCell]
table_cells: List[TableCell] = []
num_rows: int = 0
num_cols: int = 0

Expand Down Expand Up @@ -184,7 +184,7 @@ class Section(TextItem):


class FloatingItem(DocItem):
caption: Optional[RefItem] = None
captions: List[RefItem] = []
references: List[RefItem] = []
footnotes: List[RefItem] = []
image: Optional[ImageRef] = None
Expand Down Expand Up @@ -333,7 +333,7 @@ def add_figure(
if prov:
fig_item.prov.append(prov)
if caption:
fig_item.caption = caption.get_ref()
fig_item.captions.append(caption.get_ref())

self.figures.append(fig_item)
parent.children.append(RefItem(cref=cref))
Expand Down
4 changes: 2 additions & 2 deletions test/data/experimental/dummy_doc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ figures: # All figures...
label: "figure"
parent:
$ref: "#/body"
caption:
$ref: "/texts/3"
captions:
- $ref: "/texts/3"
data: # BaseFigureData Type
classification: "illustration"
confidence: 0.78
Expand Down

0 comments on commit 425858a

Please sign in to comment.