ontocast.tool.validate¶
Validation tools for OntoCast.
This module provides functionality for validating RDF graphs and chunks, including connectivity validation and graph structure verification.
ConnectivityResult
¶
Bases: BaseModel
Type definition for connectivity validation results.
Source code in ontocast/tool/validate.py
PredicateStats
¶
Bases: BaseModel
Type definition for predicate statistics.
Source code in ontocast/tool/validate.py
PredicateValidationResult
¶
Bases: BaseModel
Type definition for predicate validation results.
Source code in ontocast/tool/validate.py
RDFGraphConnectivityValidator
¶
Validator for RDF graph connectivity.
This class provides functionality for validating and ensuring connectivity in RDF graphs, including finding connected components and adding bridging relationships.
Attributes:
| Name | Type | Description |
|---|---|---|
graph |
The RDF graph to validate. |
Source code in ontocast/tool/validate.py
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 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 | |
__init__(graph)
¶
Initialize the validator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
RDFGraph
|
The RDF graph to validate. |
required |
build_adjacency_graph()
¶
Build an adjacency representation of the RDF graph.
Returns:
| Type | Description |
|---|---|
dict[URIRef, set[URIRef]]
|
dict[URIRef, set[URIRef]]: Dictionary mapping entities to their neighbors. |
Source code in ontocast/tool/validate.py
find_connected_components()
¶
Find all connected components in the graph using BFS.
Returns:
| Type | Description |
|---|---|
list[set[URIRef]]
|
list[set[URIRef]]: List of sets, each containing entities in a component. |
Source code in ontocast/tool/validate.py
get_all_entities()
¶
Extract all unique entities from the graph.
Returns:
| Type | Description |
|---|---|
set[URIRef]
|
set[URIRef]: Set of all unique entity URIs in the graph. |
Source code in ontocast/tool/validate.py
make_graph_connected(chunk_iri)
¶
Make a disconnected graph connected by adding bridging relationships.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk_iri
|
The IRI of the chunk to use for the hub entity. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RDFGraph |
RDFGraph
|
A new connected graph. |
Source code in ontocast/tool/validate.py
validate_connectivity()
¶
Validate graph connectivity and return detailed results.
Returns:
| Name | Type | Description |
|---|---|---|
ConnectivityResult |
ConnectivityResult
|
Pydantic model containing connectivity information and validation results. |
Source code in ontocast/tool/validate.py
validate_predicates()
¶
Validate predicate consistency and required properties.
Returns:
| Name | Type | Description |
|---|---|---|
PredicateValidationResult |
PredicateValidationResult
|
Pydantic model containing validation results and statistics. |
Source code in ontocast/tool/validate.py
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
partition_object_property_literal_triples(facts_graph, ontology_graph)
¶
Split facts into a clean graph and quarantined literal-on-object-property triples.
A string literal on a predicate whose schema range is a class (e.g.
qudt:unit with range qudt:Unit) silently breaks typing: the value can
never be linked to the reference individual it names. Such triples are
quarantined with a reason so the critic loop can ask the renderer to resolve
the token to an IRI from the ontology context instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
facts_graph
|
RDFGraph
|
Freshly rendered facts graph. |
required |
ontology_graph
|
Graph
|
Ontology context the facts were rendered against. |
required |
Returns:
| Type | Description |
|---|---|
tuple[RDFGraph, list[RejectedLiteralTriple]]
|
Tuple of (clean graph, quarantined triples). |
Source code in ontocast/tool/validate.py
validate_and_connect_content_unit(unit, auto_connect=True)
¶
Validate and optionally connect a content unit graph.
This function validates the connectivity of a content unit RDF graph and optionally connects any disconnected components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit
|
ContentUnit
|
The content unit containing the RDF graph to validate. |
required |
auto_connect
|
bool
|
Whether to automatically connect disconnected graphs. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
ContentUnit |
ContentUnit
|
The content unit with a validated and optionally connected graph. |