ontocast.tool.converter¶
Document conversion tools for OntoCast.
This module provides functionality for converting various document formats into structured data that can be processed by the OntoCast system.
ConverterTool
¶
Bases: Tool
Tool for converting documents to native DoclingDocument format.
This class provides functionality for converting various document formats into DoclingDocument objects that can be processed by the OntoCast system. It includes caching to avoid re-converting the same documents.
Attributes:
| Name | Type | Description |
|---|---|---|
supported_extensions |
set[str]
|
Set of supported file extensions. |
cache |
Any
|
Cacher instance for caching conversion results. |
Source code in ontocast/tool/converter.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | |
__call__(file_input)
¶
Convert a document to a DoclingDocument.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_input
|
bytes | str | Path
|
The input file as either bytes, string, or pathlib.Path. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
DoclingDocument |
DoclingDocument
|
The converted document. |
Source code in ontocast/tool/converter.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | |
__init__(cache=None, converter_config=None, **kwargs)
¶
Initialize the converter tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cache
|
Cacher | None
|
Optional shared Cacher instance. If None, creates a new one. |
None
|
**kwargs
|
Additional keyword arguments passed to the parent class. |
{}
|
Source code in ontocast/tool/converter.py
ensure_converter()
¶
Return the Docling converter, building it once on first use.
Exposed so a server can warm the models at startup instead of making the first request pay for loading the layout, OCR and table-structure models.
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The shared docling |
Any
|
docling is an optional dependency resolved lazily. |
Source code in ontocast/tool/converter.py
build_document_converter(config)
¶
Build a Docling DocumentConverter from OntoCast converter settings.