docling-core 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of docling-core might be problematic. Click here for more details.

Files changed (45) hide show
  1. docling_core-0.0.1/LICENSE +21 -0
  2. docling_core-0.0.1/PKG-INFO +133 -0
  3. docling_core-0.0.1/README.md +96 -0
  4. docling_core-0.0.1/docling_core/__init__.py +6 -0
  5. docling_core-0.0.1/docling_core/py.typed +0 -0
  6. docling_core-0.0.1/docling_core/resources/schemas/doc/ANN.json +171 -0
  7. docling_core-0.0.1/docling_core/resources/schemas/doc/DOC.json +300 -0
  8. docling_core-0.0.1/docling_core/resources/schemas/doc/OCR-output.json +166 -0
  9. docling_core-0.0.1/docling_core/resources/schemas/doc/RAW.json +158 -0
  10. docling_core-0.0.1/docling_core/resources/schemas/generated/ccs_document_schema.json +1071 -0
  11. docling_core-0.0.1/docling_core/resources/schemas/generated/minimal_document_schema_flat.json +1129 -0
  12. docling_core-0.0.1/docling_core/resources/schemas/search/search_doc_mapping.json +104 -0
  13. docling_core-0.0.1/docling_core/resources/schemas/search/search_doc_mapping_v2.json +256 -0
  14. docling_core-0.0.1/docling_core/search/__init__.py +6 -0
  15. docling_core-0.0.1/docling_core/search/json_schema_to_search_mapper.py +406 -0
  16. docling_core-0.0.1/docling_core/search/mapping.py +29 -0
  17. docling_core-0.0.1/docling_core/search/meta.py +93 -0
  18. docling_core-0.0.1/docling_core/search/package.py +56 -0
  19. docling_core-0.0.1/docling_core/types/__init__.py +25 -0
  20. docling_core-0.0.1/docling_core/types/base.py +248 -0
  21. docling_core-0.0.1/docling_core/types/doc/__init__.py +6 -0
  22. docling_core-0.0.1/docling_core/types/doc/base.py +199 -0
  23. docling_core-0.0.1/docling_core/types/doc/doc_ann.py +76 -0
  24. docling_core-0.0.1/docling_core/types/doc/doc_ocr.py +83 -0
  25. docling_core-0.0.1/docling_core/types/doc/doc_raw.py +187 -0
  26. docling_core-0.0.1/docling_core/types/doc/document.py +393 -0
  27. docling_core-0.0.1/docling_core/types/gen/__init__.py +6 -0
  28. docling_core-0.0.1/docling_core/types/gen/generic.py +33 -0
  29. docling_core-0.0.1/docling_core/types/nlp/__init__.py +6 -0
  30. docling_core-0.0.1/docling_core/types/nlp/qa.py +74 -0
  31. docling_core-0.0.1/docling_core/types/nlp/qa_labels.py +118 -0
  32. docling_core-0.0.1/docling_core/types/rec/__init__.py +6 -0
  33. docling_core-0.0.1/docling_core/types/rec/attribute.py +55 -0
  34. docling_core-0.0.1/docling_core/types/rec/base.py +90 -0
  35. docling_core-0.0.1/docling_core/types/rec/predicate.py +133 -0
  36. docling_core-0.0.1/docling_core/types/rec/record.py +95 -0
  37. docling_core-0.0.1/docling_core/types/rec/statement.py +41 -0
  38. docling_core-0.0.1/docling_core/types/rec/subject.py +77 -0
  39. docling_core-0.0.1/docling_core/utils/__init__.py +6 -0
  40. docling_core-0.0.1/docling_core/utils/alias.py +27 -0
  41. docling_core-0.0.1/docling_core/utils/ds_generate_docs.py +144 -0
  42. docling_core-0.0.1/docling_core/utils/ds_generate_jsonschema.py +62 -0
  43. docling_core-0.0.1/docling_core/utils/validate.py +86 -0
  44. docling_core-0.0.1/docling_core/utils/validators.py +100 -0
  45. docling_core-0.0.1/pyproject.toml +128 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 International Business Machines
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,133 @@
1
+ Metadata-Version: 2.1
2
+ Name: docling-core
3
+ Version: 0.0.1
4
+ Summary: A python library to define and validate data types in Docling.
5
+ Home-page: https://ds4sd.github.io/
6
+ License: MIT
7
+ Keywords: docling,discovery,etl,information retrieval,analytics,database,database schema,schema,JSON
8
+ Author: Cesar Berrospi Ramis
9
+ Author-email: ceb@zurich.ibm.com
10
+ Maintainer: Cesar Berrospi Ramis
11
+ Maintainer-email: ceb@zurich.ibm.com
12
+ Requires-Python: >=3.9,<4.0
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Natural Language :: English
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Topic :: Database
25
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
26
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
27
+ Classifier: Typing :: Typed
28
+ Requires-Dist: json-schema-for-humans (>=1.0.0,<2.0.0)
29
+ Requires-Dist: jsonref (>=1.1.0,<2.0.0)
30
+ Requires-Dist: jsonschema (>=4.16.0,<5.0.0)
31
+ Requires-Dist: poetry (>=1.8.3,<2.0.0)
32
+ Requires-Dist: pydantic (>=2.6.0,<3.0.0)
33
+ Requires-Dist: pyproject-toml (>=0.0.10,<0.0.11)
34
+ Project-URL: Repository, https://github.com/DS4SD/docling-core
35
+ Description-Content-Type: text/markdown
36
+
37
+ [![PyPI version](https://img.shields.io/pypi/v/docling-core)](https://pypi.org/project/docling-core/)
38
+ ![Python](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11-blue)
39
+ [![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)
40
+ [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
41
+ [![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
42
+ [![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)
43
+ [![Pydantic v2](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/main/docs/badge/v2.json)](https://pydantic.dev)
44
+ [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
45
+ [![License MIT](https://img.shields.io/github/license/ds4sd/deepsearch-toolkit)](https://opensource.org/licenses/MIT)
46
+
47
+ # Docling Core
48
+
49
+ Docling Core is a library that defines the data types in [Docling](https://ds4sd.github.io), leveraging pydantic models.
50
+
51
+ ## Installation
52
+
53
+ Using [Poetry](https://python-poetry.org), create and activate a virtual environment.
54
+
55
+ ```
56
+ poetry shell
57
+ ```
58
+
59
+ Install the defined dependencies of the project.
60
+
61
+ ```
62
+ poetry install
63
+ ```
64
+
65
+ Test the installation running the pytest suite.
66
+
67
+ ```
68
+ poetry run pytest test
69
+ ```
70
+
71
+ ## Basic Usage
72
+
73
+ - You can validate your JSON objects using the pydantic class definition.
74
+
75
+ ```py
76
+ from docling_core.types import Document
77
+
78
+ data_dict = {...} # here the object you want to validate, as a dictionary
79
+ Document.model_validate(data_dict)
80
+
81
+ data_str = {...} # here the object as a JSON string
82
+ Document.model_validate_json(data_str)
83
+ ```
84
+
85
+ - You can generate the JSON schema of a model with the script `ds_generate_jsonschema`.
86
+
87
+ ```py
88
+ # for the `Document` type
89
+ ds_generate_jsonschema Document
90
+
91
+ # for the use `Record` type
92
+ ds_generate_jsonschema Record
93
+ ```
94
+
95
+ ## Documentation
96
+
97
+ Docling supports 3 main data types:
98
+
99
+ - **Document** for publications like books, articles, reports, or patents. When Docling converts an unstructured PDF document, the generated JSON follows this schema.
100
+ The Document type also models the metadata that may be attached to the converted document.
101
+ Check [Document](docs/Document.md) for the full JSON schema.
102
+ - **Record** for structured database records, centered on an entity or _subject_ that is provided with a list of attributes.
103
+ Related to records, the statements can represent annotations on text by Natural Language Processing (NLP) tools.
104
+ Check [Record](docs/Record.md) for the full JSON schema.
105
+ - **Generic** for any data representation, ensuring minimal configuration and maximum flexibility.
106
+ Check [Generic](docs/Generic.md) for the full JSON schema.
107
+
108
+ The data schemas are defined using [pydantic](https://pydantic-docs.helpmanual.io/) models, which provide built-in processes to support the creation of data that adhere to those models.
109
+
110
+ ## Contributing
111
+
112
+ Please read [Contributing to Docling Core](./CONTRIBUTING.md) for details.
113
+
114
+ ## References
115
+
116
+ If you use `Docling Core` in your projects, please consider citing the following:
117
+
118
+ ```bib
119
+ @software{Docling,
120
+ author = {Deep Search Team},
121
+ month = {7},
122
+ title = {{Docling}},
123
+ url = {https://github.com/DS4SD/docling},
124
+ version = {main},
125
+ year = {2024}
126
+ }
127
+ ```
128
+
129
+ ## License
130
+
131
+ The `Docling Core` codebase is under MIT license.
132
+ For individual model usage, please refer to the model licenses found in the original packages.
133
+
@@ -0,0 +1,96 @@
1
+ [![PyPI version](https://img.shields.io/pypi/v/docling-core)](https://pypi.org/project/docling-core/)
2
+ ![Python](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11-blue)
3
+ [![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)
4
+ [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
5
+ [![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
6
+ [![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)
7
+ [![Pydantic v2](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/main/docs/badge/v2.json)](https://pydantic.dev)
8
+ [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
9
+ [![License MIT](https://img.shields.io/github/license/ds4sd/deepsearch-toolkit)](https://opensource.org/licenses/MIT)
10
+
11
+ # Docling Core
12
+
13
+ Docling Core is a library that defines the data types in [Docling](https://ds4sd.github.io), leveraging pydantic models.
14
+
15
+ ## Installation
16
+
17
+ Using [Poetry](https://python-poetry.org), create and activate a virtual environment.
18
+
19
+ ```
20
+ poetry shell
21
+ ```
22
+
23
+ Install the defined dependencies of the project.
24
+
25
+ ```
26
+ poetry install
27
+ ```
28
+
29
+ Test the installation running the pytest suite.
30
+
31
+ ```
32
+ poetry run pytest test
33
+ ```
34
+
35
+ ## Basic Usage
36
+
37
+ - You can validate your JSON objects using the pydantic class definition.
38
+
39
+ ```py
40
+ from docling_core.types import Document
41
+
42
+ data_dict = {...} # here the object you want to validate, as a dictionary
43
+ Document.model_validate(data_dict)
44
+
45
+ data_str = {...} # here the object as a JSON string
46
+ Document.model_validate_json(data_str)
47
+ ```
48
+
49
+ - You can generate the JSON schema of a model with the script `ds_generate_jsonschema`.
50
+
51
+ ```py
52
+ # for the `Document` type
53
+ ds_generate_jsonschema Document
54
+
55
+ # for the use `Record` type
56
+ ds_generate_jsonschema Record
57
+ ```
58
+
59
+ ## Documentation
60
+
61
+ Docling supports 3 main data types:
62
+
63
+ - **Document** for publications like books, articles, reports, or patents. When Docling converts an unstructured PDF document, the generated JSON follows this schema.
64
+ The Document type also models the metadata that may be attached to the converted document.
65
+ Check [Document](docs/Document.md) for the full JSON schema.
66
+ - **Record** for structured database records, centered on an entity or _subject_ that is provided with a list of attributes.
67
+ Related to records, the statements can represent annotations on text by Natural Language Processing (NLP) tools.
68
+ Check [Record](docs/Record.md) for the full JSON schema.
69
+ - **Generic** for any data representation, ensuring minimal configuration and maximum flexibility.
70
+ Check [Generic](docs/Generic.md) for the full JSON schema.
71
+
72
+ The data schemas are defined using [pydantic](https://pydantic-docs.helpmanual.io/) models, which provide built-in processes to support the creation of data that adhere to those models.
73
+
74
+ ## Contributing
75
+
76
+ Please read [Contributing to Docling Core](./CONTRIBUTING.md) for details.
77
+
78
+ ## References
79
+
80
+ If you use `Docling Core` in your projects, please consider citing the following:
81
+
82
+ ```bib
83
+ @software{Docling,
84
+ author = {Deep Search Team},
85
+ month = {7},
86
+ title = {{Docling}},
87
+ url = {https://github.com/DS4SD/docling},
88
+ version = {main},
89
+ year = {2024}
90
+ }
91
+ ```
92
+
93
+ ## License
94
+
95
+ The `Docling Core` codebase is under MIT license.
96
+ For individual model usage, please refer to the model licenses found in the original packages.
@@ -0,0 +1,6 @@
1
+ #
2
+ # Copyright IBM Corp. 2024 - 2024
3
+ # SPDX-License-Identifier: MIT
4
+ #
5
+
6
+ """Main package."""
File without changes
@@ -0,0 +1,171 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema#",
3
+ "definitions": {
4
+ "annot+pred": {
5
+ "type": "array",
6
+ "items": {
7
+ "type": "object",
8
+ "required": [
9
+ "cells",
10
+ "clusters",
11
+ "tables",
12
+ "source"
13
+ ],
14
+ "properties": {
15
+ "cells": {
16
+ "type": "array",
17
+ "items": {
18
+ "type": "object",
19
+ "required": [
20
+ "id",
21
+ "rawcell_id",
22
+ "label"
23
+ ],
24
+ "properties": {
25
+ "id": {
26
+ "type": "integer"
27
+ },
28
+ "rawcell_id": {
29
+ "type": "integer"
30
+ },
31
+ "label": {
32
+ "type": "string"
33
+ }
34
+ }
35
+ }
36
+ },
37
+ "clusters": {
38
+ "type": "array",
39
+ "items": {
40
+ "type": "object",
41
+ "required": [
42
+ "model",
43
+ "type",
44
+ "bbox",
45
+ "cell_ids",
46
+ "merged",
47
+ "id"
48
+ ],
49
+ "properties": {
50
+ "model": {
51
+ "type": "string"
52
+ },
53
+ "type": {
54
+ "type": "string"
55
+ },
56
+ "bbox": {
57
+ "type": "array",
58
+ "minItems": 4,
59
+ "maxItems": 4,
60
+ "items": {
61
+ "type": "number"
62
+ }
63
+ },
64
+ "cell_ids": {
65
+ "type": "array",
66
+ "items": {
67
+ "type": "integer"
68
+ }
69
+ },
70
+ "merged": {
71
+ "type": "boolean"
72
+ },
73
+ "id": {
74
+ "type": "integer"
75
+ }
76
+ }
77
+ }
78
+ },
79
+ "tables": {
80
+ "type": "array",
81
+ "items": {
82
+ "type": "object",
83
+ "required": [
84
+ "cell_id",
85
+ "label",
86
+ "rows",
87
+ "cols"
88
+ ],
89
+ "properties": {
90
+ "cell_id": {
91
+ "type": "integer"
92
+ },
93
+ "label": {
94
+ "type": "string"
95
+ },
96
+ "rows": {
97
+ "type": "array",
98
+ "items": {
99
+ "type": "integer"
100
+ }
101
+ },
102
+ "cols": {
103
+ "type": "array",
104
+ "items": {
105
+ "type": "integer"
106
+ }
107
+ }
108
+ }
109
+ }
110
+ },
111
+ "source": {
112
+ "type": "object",
113
+ "required": [
114
+ "type",
115
+ "info",
116
+ "timestamp"
117
+ ],
118
+ "properties": {
119
+ "type": {
120
+ "type": "string"
121
+ },
122
+ "timestamp": {
123
+ "type": "number"
124
+ },
125
+ "info": {
126
+ "type": "object",
127
+ "required": [
128
+ "display_name",
129
+ "model_name",
130
+ "model_class",
131
+ "model_version",
132
+ "model_id"
133
+ ],
134
+ "properties": {
135
+ "display_name": {
136
+ "type": "string"
137
+ },
138
+ "model_name": {
139
+ "type": "string"
140
+ },
141
+ "model_class": {
142
+ "type": "string"
143
+ },
144
+ "model_version": {
145
+ "type": "string"
146
+ },
147
+ "model_id": {
148
+ "type": "string"
149
+ }
150
+ }
151
+ }
152
+ }
153
+ }
154
+ }
155
+ }
156
+ }
157
+ },
158
+ "properties": {
159
+ "annotations": {
160
+ "$ref": "#/definitions/annot+pred"
161
+ },
162
+ "predictions": {
163
+ "$ref": "#/definitions/annot+pred"
164
+ },
165
+ "reports": {
166
+ "type": "array"
167
+ }
168
+ },
169
+ "minProperties": 1,
170
+ "type": "object"
171
+ }