Skip to content

Commit

Permalink
Moved image attribute from FloatingItem to DocItem
Browse files Browse the repository at this point in the history
Signed-off-by: Shubham Gupta <[email protected]>
  • Loading branch information
sh-gupta committed Nov 14, 2024
1 parent 50bbe29 commit cbbcec0
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 23 deletions.
2 changes: 1 addition & 1 deletion docling_core/types/doc/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ class DocItem(

label: DocItemLabel
prov: List[ProvenanceItem] = []
image: Optional[ImageRef] = None

def get_location_tokens(
self,
Expand Down Expand Up @@ -624,7 +625,6 @@ class FloatingItem(DocItem):
captions: List[RefItem] = []
references: List[RefItem] = []
footnotes: List[RefItem] = []
image: Optional[ImageRef] = None

def caption_text(self, doc: "DoclingDocument") -> str:
"""Computes the caption as a single text."""
Expand Down
88 changes: 66 additions & 22 deletions docs/DoclingDocument.json
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,17 @@
},
"title": "Prov",
"type": "array"
},
"image": {
"anyOf": [
{
"$ref": "#/$defs/ImageRef"
},
{
"type": "null"
}
],
"default": null
}
},
"required": [
Expand Down Expand Up @@ -417,6 +428,17 @@
"title": "Prov",
"type": "array"
},
"image": {
"anyOf": [
{
"$ref": "#/$defs/ImageRef"
},
{
"type": "null"
}
],
"default": null
},
"orig": {
"title": "Orig",
"type": "string"
Expand Down Expand Up @@ -637,6 +659,17 @@
"title": "Prov",
"type": "array"
},
"image": {
"anyOf": [
{
"$ref": "#/$defs/ImageRef"
},
{
"type": "null"
}
],
"default": null
},
"captions": {
"default": [],
"items": {
Expand All @@ -661,17 +694,6 @@
"title": "Footnotes",
"type": "array"
},
"image": {
"anyOf": [
{
"$ref": "#/$defs/ImageRef"
},
{
"type": "null"
}
],
"default": null
},
"annotations": {
"default": [],
"items": {
Expand Down Expand Up @@ -1055,6 +1077,17 @@
"title": "Prov",
"type": "array"
},
"image": {
"anyOf": [
{
"$ref": "#/$defs/ImageRef"
},
{
"type": "null"
}
],
"default": null
},
"orig": {
"title": "Orig",
"type": "string"
Expand Down Expand Up @@ -1236,6 +1269,17 @@
"title": "Prov",
"type": "array"
},
"image": {
"anyOf": [
{
"$ref": "#/$defs/ImageRef"
},
{
"type": "null"
}
],
"default": null
},
"captions": {
"default": [],
"items": {
Expand All @@ -1260,17 +1304,6 @@
"title": "Footnotes",
"type": "array"
},
"image": {
"anyOf": [
{
"$ref": "#/$defs/ImageRef"
},
{
"type": "null"
}
],
"default": null
},
"data": {
"$ref": "#/$defs/TableData"
}
Expand Down Expand Up @@ -1321,6 +1354,17 @@
"title": "Prov",
"type": "array"
},
"image": {
"anyOf": [
{
"$ref": "#/$defs/ImageRef"
},
{
"type": "null"
}
],
"default": null
},
"orig": {
"title": "Orig",
"type": "string"
Expand Down
1 change: 1 addition & 0 deletions test/data/docling_document/unit/KeyValueItem.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
children: []
image: null
label: text
parent: null
prov: []
Expand Down
1 change: 1 addition & 0 deletions test/data/docling_document/unit/ListItem.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
children: []
enumerated: true
image: null
label: list_item
marker: (1)
orig: whatever
Expand Down
1 change: 1 addition & 0 deletions test/data/docling_document/unit/SectionHeaderItem.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
children: []
image: null
label: section_header
level: 2
orig: whatever
Expand Down
1 change: 1 addition & 0 deletions test/data/docling_document/unit/TextItem.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
children: []
image: null
label: text
orig: whatever
parent: null
Expand Down

0 comments on commit cbbcec0

Please sign in to comment.