Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make page number strictly positive #8

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docling_core/types/doc/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""Define common models across CCS objects."""
from typing import Annotated, Literal, Optional, Union

from pydantic import BaseModel, Field, StrictStr
from pydantic import BaseModel, Field, PositiveInt, StrictStr

from docling_core.search.mapping import es_field
from docling_core.utils.alias import AliasModel
Expand Down Expand Up @@ -39,7 +39,7 @@ class S3Resource(BaseModel):

mime: str
path: str
page: Optional[int] = None
page: Optional[PositiveInt] = None


class S3Data(AliasModel):
Expand Down Expand Up @@ -68,7 +68,7 @@ class Prov(AliasModel):
"""Provenance."""

bbox: BoundingBox
page: int
page: PositiveInt
span: Span
ref_s3_data: Optional[StrictStr] = Field(
default=None, alias="__ref_s3_data", json_schema_extra=es_field(suppress=True)
Expand Down Expand Up @@ -96,7 +96,7 @@ class PageDimensions(BaseModel):
"""Page dimensions."""

height: float
page: int
page: PositiveInt
width: float


Expand Down Expand Up @@ -196,4 +196,4 @@ class PageReference(BaseModel):

hash: str = Field(json_schema_extra=es_field(type="keyword", ignore_above=8191))
model: str = Field(json_schema_extra=es_field(suppress=True))
page: int = Field(json_schema_extra=es_field(type="short"))
page: PositiveInt = Field(json_schema_extra=es_field(type="short"))
4 changes: 4 additions & 0 deletions docs/Document.json
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,7 @@
"type": "number"
},
"page": {
"exclusiveMinimum": 0,
"title": "Page",
"type": "integer"
},
Expand Down Expand Up @@ -1219,6 +1220,7 @@
"x-es-suppress": true
},
"page": {
"exclusiveMinimum": 0,
"title": "Page",
"type": "integer",
"x-es-type": "short"
Expand All @@ -1245,6 +1247,7 @@
"type": "array"
},
"page": {
"exclusiveMinimum": 0,
"title": "Page",
"type": "integer"
},
Expand Down Expand Up @@ -1547,6 +1550,7 @@
"page": {
"anyOf": [
{
"exclusiveMinimum": 0,
"type": "integer"
},
{
Expand Down
68 changes: 68 additions & 0 deletions docs/Document.md
Original file line number Diff line number Diff line change
Expand Up @@ -3598,6 +3598,10 @@ Must be one of:
| **Type** | `integer` |
| **Required** | Yes |

| Restrictions | |
| ------------ | ------ |
| **Minimum** | > 0 |

</blockquote>
</details>

Expand Down Expand Up @@ -3995,6 +3999,10 @@ Must be one of:
| **Type** | `integer` |
| **Required** | Yes |

| Restrictions | |
| ------------ | ------ |
| **Minimum** | &gt; 0 |

</blockquote>
</details>

Expand Down Expand Up @@ -4404,6 +4412,10 @@ Must be one of:
| **Type** | `integer` |
| **Required** | Yes |

| Restrictions | |
| ------------ | ------ |
| **Minimum** | &gt; 0 |

</blockquote>
</details>

Expand Down Expand Up @@ -5732,6 +5744,10 @@ Must be one of:
| **Type** | `integer` |
| **Required** | Yes |

| Restrictions | |
| ------------ | ------ |
| **Minimum** | &gt; 0 |

</blockquote>
</details>

Expand Down Expand Up @@ -6149,6 +6165,10 @@ Must be one of:
| **Type** | `integer` |
| **Required** | Yes |

| Restrictions | |
| ------------ | ------ |
| **Minimum** | &gt; 0 |

</blockquote>
</details>

Expand Down Expand Up @@ -6540,6 +6560,10 @@ Must be one of:
| **Type** | `integer` |
| **Required** | Yes |

| Restrictions | |
| ------------ | ------ |
| **Minimum** | &gt; 0 |

</blockquote>
</details>

Expand Down Expand Up @@ -7020,6 +7044,10 @@ Must be one of:
| **Type** | `integer` |
| **Required** | Yes |

| Restrictions | |
| ------------ | ------ |
| **Minimum** | &gt; 0 |

</blockquote>
</details>

Expand Down Expand Up @@ -7228,6 +7256,10 @@ Must be one of:
| **Type** | `integer` |
| **Required** | Yes |

| Restrictions | |
| ------------ | ------ |
| **Minimum** | &gt; 0 |

</blockquote>
</details>

Expand Down Expand Up @@ -7557,6 +7589,10 @@ Must be one of:
| **Type** | `integer` |
| **Required** | Yes |

| Restrictions | |
| ------------ | ------ |
| **Minimum** | &gt; 0 |

</blockquote>
</details>

Expand Down Expand Up @@ -7971,6 +8007,10 @@ Must be one of:
| **Type** | `integer` |
| **Required** | Yes |

| Restrictions | |
| ------------ | ------ |
| **Minimum** | &gt; 0 |

</blockquote>
</details>

Expand Down Expand Up @@ -8248,6 +8288,10 @@ Must be one of:
| **Type** | `integer` |
| **Required** | No |

| Restrictions | |
| ------------ | ------ |
| **Minimum** | &gt; 0 |

</blockquote>
<blockquote>

Expand Down Expand Up @@ -8403,6 +8447,10 @@ Must be one of:
| **Type** | `integer` |
| **Required** | No |

| Restrictions | |
| ------------ | ------ |
| **Minimum** | &gt; 0 |

</blockquote>
<blockquote>

Expand Down Expand Up @@ -8558,6 +8606,10 @@ Must be one of:
| **Type** | `integer` |
| **Required** | No |

| Restrictions | |
| ------------ | ------ |
| **Minimum** | &gt; 0 |

</blockquote>
<blockquote>

Expand Down Expand Up @@ -8692,6 +8744,10 @@ Must be one of:
| **Type** | `integer` |
| **Required** | No |

| Restrictions | |
| ------------ | ------ |
| **Minimum** | &gt; 0 |

</blockquote>
<blockquote>

Expand Down Expand Up @@ -8826,6 +8882,10 @@ Must be one of:
| **Type** | `integer` |
| **Required** | No |

| Restrictions | |
| ------------ | ------ |
| **Minimum** | &gt; 0 |

</blockquote>
<blockquote>

Expand Down Expand Up @@ -8960,6 +9020,10 @@ Must be one of:
| **Type** | `integer` |
| **Required** | No |

| Restrictions | |
| ------------ | ------ |
| **Minimum** | &gt; 0 |

</blockquote>
<blockquote>

Expand Down Expand Up @@ -9115,6 +9179,10 @@ Must be one of:
| **Type** | `integer` |
| **Required** | No |

| Restrictions | |
| ------------ | ------ |
| **Minimum** | &gt; 0 |

</blockquote>
<blockquote>

Expand Down
Loading