Core classes and methods#

Entity #

Bases: BaseModel

The base class of all ontology classes.

Parameters:

Name Type Description Default
id str

IRI

required
Source code in pydontology/pydontology.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class Entity(BaseModel):
    """The base class of all ontology classes.

    Args:
        id (str): IRI
    """

    id: str = Field(alias="@id", description="IRI (possibly relative)", title="@id")

    @computed_field(alias="@type", title="@type", description="JSON-LD @type")
    @property
    def type(self) -> str:
        return type(self).__name__

    model_config = ConfigDict(populate_by_name=True, serialize_by_alias=True)

JSONLDGraph #

Bases: BaseModel

Encapsulates a JSON-LD document/graph.

This is the return type of the make_model() function, and ontology_graph(), shacl_graph() class methods.

Parameters:

Name Type Description Default
context dict

JSON-LD context (mapped to @context)

required
graph List

Default graph containing entities (mapped to @graph)

required
Source code in pydontology/pydontology.py
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
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
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
class JSONLDGraph(BaseModel):
    """Encapsulates a JSON-LD document/graph.

    This is the return type of the make_model() function, and
    ontology_graph(), shacl_graph() class methods.

    Args:
        context (dict): JSON-LD context (mapped to @context)
        graph (List): Default graph containing entities (mapped to @graph)
    """

    context: SkipJsonSchema[dict] = Field(
        default={
            "@vocab": "http://example.com/vocab/",
            "@base": "http://example.com/",
        },
        alias="@context",
        title="@context",
        description="JSON-LD context",
    )

    graph: List = Field(
        default=[], alias="@graph", title="@graph", description="Default graph"
    )

    model_config = ConfigDict(populate_by_name=True, serialize_by_alias=True)

    @classmethod
    def ontology_graph(cls) -> "JSONLDGraph":
        """Generate an ontology graph from the classes in the ontology.

        Returns:
            JSONLDGraph: With _OntologyClass and _OntologyProperty (internal classes) instances.
        """

        # Collect unique entity types from the model
        entity_classes = cls._collect_entity_classes_from_model()

        # Generate class and property definitions
        ontology_entities: List[_OntologyClass | _OntologyProperty] = []
        properties_seen = set()

        for entity_class in entity_classes:
            # Add class definition
            class_def = cls._create_class_definition(entity_class, entity_classes)
            ontology_entities.append(class_def)

            # Add property definitions
            property_defs = cls._create_property_definitions(
                entity_class, properties_seen
            )
            ontology_entities.extend(property_defs)

        # Extract vocab from context
        vocab = cls.model_fields["context"].default.get(
            "@vocab", "http://example.com/vocab/"
        )

        # Build ontology context
        ontology_context = {
            "@vocab": vocab,
            "@base": vocab,
            "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
            "owl": "http://www.w3.org/2002/07/owl#",
        }

        # Return as JSONLDGraph
        return JSONLDGraph(context=ontology_context, graph=ontology_entities)

    @classmethod
    def shacl_graph(cls) -> "JSONLDGraph":
        """Generate SHACL shapes graph from the classes in the ontology.

        Returns:
            JSONLDGraph: With _NodeShape and _PropertyShape (internal classes) instances.
        """

        # Collect unique entity types from the model
        entity_classes = cls._collect_entity_classes_from_model()

        # Generate node shapes
        shacl_shapes: List[_NodeShape] = []

        for entity_class in entity_classes:
            # Create node shape for this class
            node_shape = cls._create_node_shape(entity_class)
            shacl_shapes.append(node_shape)

        # Extract vocab from context
        vocab = cls.model_fields["context"].default.get(
            "@vocab", "http://example.com/vocab/"
        )

        # Build SHACL context
        shacl_context = {
            "@vocab": vocab,
            "@base": vocab,
            "sh": "http://www.w3.org/ns/shacl#",
            "xsd": "http://www.w3.org/2001/XMLSchema#",
        }

        # Return as JSONLDGraph
        return JSONLDGraph(context=shacl_context, graph=shacl_shapes)

    @classmethod
    def _collect_entity_classes_from_model(cls) -> set:
        """Collect all Entity classes from the model's graph field type annotation.

        Returns:
            set: All Entity classes found in the model's graph field annotation.
        """
        entity_classes = set()

        # Get the graph field's annotation
        graph_field = cls.model_fields.get("graph")
        if graph_field and graph_field.annotation:
            annotation = graph_field.annotation

            # Extract the entity type from List[EntityType] or List[A|B|C]
            origin = get_origin(annotation)
            if origin is list or origin is List:
                args = get_args(annotation)
                if args:
                    inner_type = args[0]

                    # Check if inner type is a Union (A|B|C or Union[A, B, C])
                    inner_origin = get_origin(inner_type)
                    # Handle both Union[A, B, C] and A|B|C (UnionType in Python 3.10+)
                    if inner_origin is Union or isinstance(inner_type, UnionType):
                        # Handle List[A|B|C] - extract all union members
                        union_args = get_args(inner_type)
                        for entity_type in union_args:
                            if isinstance(entity_type, type) and issubclass(
                                entity_type, Entity
                            ):
                                entity_classes.add(entity_type)
                                entity_classes.update(
                                    cls._get_all_subclasses(entity_type)
                                )
                    else:
                        # Handle List[EntityType] - single entity type
                        if isinstance(inner_type, type) and issubclass(
                            inner_type, Entity
                        ):
                            entity_classes.add(inner_type)
                            entity_classes.update(cls._get_all_subclasses(inner_type))

        return entity_classes

    @classmethod
    def _get_all_subclasses(cls, entity_class) -> set:
        """Recursively get all subclasses of an entity class.

        Args:
            entity_class: The entity class to find subclasses for.

        Returns:
            set: All subclasses of the given entity class.
        """
        subclasses = set()
        for subclass in entity_class.__subclasses__():
            subclasses.add(subclass)
            subclasses.update(cls._get_all_subclasses(subclass))
        return subclasses

    @classmethod
    def _create_class_definition(
        cls, entity_class, entity_classes: set
    ) -> _OntologyClass:
        """Create an RDFS class definition for an Entity class.

        Args:
            entity_class: The Entity class to create a definition for.
            entity_classes: Set of all entity classes in the model.

        Returns:
            _OntologyClass: RDFS class definition.
        """
        class_def = _OntologyClass(
            id=entity_class.__name__,
            label=entity_class.__name__,
            comment=entity_class.__doc__.strip() if entity_class.__doc__ else None,
        )

        # Add inheritance relationships
        for base in entity_class.__bases__:
            if base != Entity and issubclass(base, Entity):
                class_def.subClassOf = Relation(id=base.__name__)
                entity_classes.add(base)

        return class_def

    @classmethod
    def _create_property_definitions(
        cls, entity_class, properties_seen: set
    ) -> List[_OntologyProperty]:
        """Create property definitions for fields defined on a class.

        Args:
            entity_class: The Entity class to create property definitions for.
            properties_seen: Set of property names already processed.

        Returns:
            List[_OntologyProperty]: Property definitions for the class fields.
        """
        property_defs = []
        parent_fields = cls._get_parent_fields(entity_class)

        for field_name, field_info in entity_class.model_fields.items():
            # Skip special fields and inherited fields
            if field_name in ["id", "type"] or field_name in parent_fields:
                continue

            # Skip duplicates
            if field_name in properties_seen:
                continue
            properties_seen.add(field_name)

            # Create property definition
            prop_def = cls._create_single_property_definition(
                entity_class, field_name, field_info, field_name
            )
            property_defs.append(prop_def)

        return property_defs

    @classmethod
    def _get_parent_fields(cls, entity_class) -> set:
        """Get all field names from parent classes.

        Args:
            entity_class: The Entity class to get parent fields for.

        Returns:
            set: Field names from all parent classes.
        """
        parent_fields = set()
        for base in entity_class.__bases__:
            if base != Entity and issubclass(base, Entity):
                parent_fields.update(base.model_fields.keys())
        return parent_fields

    @classmethod
    def _create_single_property_definition(
        cls, entity_class, field_name: str, field_info, prop_name: str
    ) -> _OntologyProperty:
        """Create a single property definition.

        Args:
            entity_class: The Entity class containing the field.
            field_name: Name of the field.
            field_info: Pydantic field information.
            prop_name: Name for the property.

        Returns:
            _OntologyProperty: Property definition for the field.
        """
        # Extract type and metadata
        field_type, metadata = cls._extract_field_type_and_metadata(
            entity_class, field_name, field_info
        )

        # Determine if ObjectProperty or DatatypeProperty
        is_relation = cls._is_relation_type(field_type)

        prop_def = _OntologyProperty(
            id=prop_name,
            type="owl:ObjectProperty" if is_relation else "owl:DatatypeProperty",
            label=prop_name,
            domain=Relation(id=entity_class.__name__),
            comment=field_info.description,
        )

        # Add properties to _OntologyProperty according to annotation
        for meta in metadata:
            if isinstance(meta, RDFSAnnotation.DOMAIN):
                prop_def.domain = Relation(id=meta.value)
            if isinstance(meta, RDFSAnnotation.RANGE):
                prop_def.range = Relation(id=meta.value)

        return prop_def

    @classmethod
    def _create_node_shape(cls, entity_class) -> _NodeShape:
        """Create a SHACL node shape for an Entity class.

        Args:
            entity_class: The Entity class to create a node shape for.

        Returns:
            _NodeShape: SHACL node shape for the entity class.
        """
        # Create property shapes for all fields
        property_shapes = []

        for field_name, field_info in entity_class.model_fields.items():
            # Skip special fields
            if field_name in ["id", "type"]:
                continue

            # Create property shape
            prop_shape = cls._create_property_shape(
                entity_class, field_name, field_info
            )
            property_shapes.append(prop_shape)

        # Create node shape
        node_shape = _NodeShape(
            id=f"{entity_class.__name__}Shape",
            targetClass=Relation(id=entity_class.__name__),
            property=property_shapes,
        )

        return node_shape

    @classmethod
    def _create_property_shape(
        cls, entity_class, field_name: str, field_info
    ) -> _PropertyShape:
        """Create a SHACL property shape for a field.

        Args:
            entity_class: The Entity class containing the field.
            field_name: Name of the field.
            field_info: Pydantic field information.

        Returns:
            _PropertyShape: SHACL property shape for the field.
        """
        # Extract type and metadata
        field_type, metadata = cls._extract_field_type_and_metadata(
            entity_class, field_name, field_info
        )

        # Determine if this is a relation
        is_relation = cls._is_relation_type(field_type)

        # Create base property shape
        prop_shape = _PropertyShape(
            id=f"{entity_class.__name__}Shape_{field_name}",
            path=Relation(id=field_name),
            name=field_name,
            description=field_info.description,
        )

        # Map Python types to XSD datatypes
        datatype_map = {
            str: "xsd:string",
            int: "xsd:integer",
            float: "xsd:decimal",
            bool: "xsd:boolean",
        }

        # Set datatype or class based on field type
        if is_relation:
            prop_shape.nodeKind = Relation(id="sh:IRI")
        else:
            if field_type in datatype_map:
                prop_shape.datatype = Relation(id=datatype_map[field_type])

        # Check if field is required (not Optional)
        if not field_info.is_required():
            # Optional field - no minCount constraint
            pass
        else:
            # Required field has minCount constraint
            prop_shape.minCount = 1

        # Apply SHACL annotations from metadata
        for meta in metadata:
            if isinstance(meta, SHACLAnnotation.DATATYPE):
                prop_shape.datatype = Relation(id=meta.value)
            elif isinstance(meta, SHACLAnnotation.MAX_COUNT):
                prop_shape.maxCount = meta.value
            elif isinstance(meta, SHACLAnnotation.MIN_COUNT):
                prop_shape.minCount = meta.value
            elif isinstance(meta, SHACLAnnotation.PATTERN):
                prop_shape.pattern = meta.value
            elif isinstance(meta, SHACLAnnotation.MIN_LENGTH):
                prop_shape.minLength = meta.value
            elif isinstance(meta, SHACLAnnotation.MAX_LENGTH):
                prop_shape.maxLength = meta.value
            elif isinstance(meta, SHACLAnnotation.MIN_INCLUSIVE):
                prop_shape.minInclusive = meta.value
            elif isinstance(meta, SHACLAnnotation.MAX_INCLUSIVE):
                prop_shape.maxInclusive = meta.value
            elif isinstance(meta, SHACLAnnotation.MIN_EXCLUSIVE):
                prop_shape.minExclusive = meta.value
            elif isinstance(meta, SHACLAnnotation.MAX_EXCLUSIVE):
                prop_shape.maxExclusive = meta.value
            elif isinstance(meta, SHACLAnnotation.NODE_KIND):
                prop_shape.nodeKind = Relation(id=meta.value)
            elif isinstance(meta, SHACLAnnotation.CLASS):
                prop_shape.shclass = Relation(id=meta.value)

        return prop_shape

    @classmethod
    def _extract_field_type_and_metadata(
        cls, entity_class, field_name: str, field_info
    ) -> tuple:
        """Extract the field type and metadata from annotations.

        Args:
            entity_class: The Entity class containing the field.
            field_name: Name of the field.
            field_info: Pydantic field information.

        Returns:
            tuple: Field type and metadata tuple.
        """
        field_type = field_info.annotation
        metadata = ()

        # Get original annotation
        original_annotation = None
        if (
            hasattr(entity_class, "__annotations__")
            and field_name in entity_class.__annotations__
        ):
            original_annotation = entity_class.__annotations__[field_name]

        # Extract metadata from Annotated
        if original_annotation and get_origin(original_annotation) is Annotated:
            args = get_args(original_annotation)
            field_type = args[0]
            metadata = args[1:]

        # Handle Optional types
        origin = getattr(field_type, "__origin__", None)
        if origin is not None:
            args = getattr(field_type, "__args__", ())
            if args:
                field_type = args[0]

        return field_type, metadata

    @classmethod
    def _is_relation_type(cls, field_type) -> bool:
        """Check if a field type is a Relation (ObjectProperty).

        Args:
            field_type: The field type to check.

        Returns:
            bool: True if the field type is a Relation, False otherwise.
        """
        try:
            if isinstance(field_type, type) and issubclass(field_type, Relation):
                return True
        except TypeError:
            pass
        return False

ontology_graph() classmethod #

Generate an ontology graph from the classes in the ontology.

Returns:

Name Type Description
JSONLDGraph JSONLDGraph

With _OntologyClass and _OntologyProperty (internal classes) instances.

Source code in pydontology/pydontology.py
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
@classmethod
def ontology_graph(cls) -> "JSONLDGraph":
    """Generate an ontology graph from the classes in the ontology.

    Returns:
        JSONLDGraph: With _OntologyClass and _OntologyProperty (internal classes) instances.
    """

    # Collect unique entity types from the model
    entity_classes = cls._collect_entity_classes_from_model()

    # Generate class and property definitions
    ontology_entities: List[_OntologyClass | _OntologyProperty] = []
    properties_seen = set()

    for entity_class in entity_classes:
        # Add class definition
        class_def = cls._create_class_definition(entity_class, entity_classes)
        ontology_entities.append(class_def)

        # Add property definitions
        property_defs = cls._create_property_definitions(
            entity_class, properties_seen
        )
        ontology_entities.extend(property_defs)

    # Extract vocab from context
    vocab = cls.model_fields["context"].default.get(
        "@vocab", "http://example.com/vocab/"
    )

    # Build ontology context
    ontology_context = {
        "@vocab": vocab,
        "@base": vocab,
        "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
        "owl": "http://www.w3.org/2002/07/owl#",
    }

    # Return as JSONLDGraph
    return JSONLDGraph(context=ontology_context, graph=ontology_entities)

shacl_graph() classmethod #

Generate SHACL shapes graph from the classes in the ontology.

Returns:

Name Type Description
JSONLDGraph JSONLDGraph

With _NodeShape and _PropertyShape (internal classes) instances.

Source code in pydontology/pydontology.py
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
@classmethod
def shacl_graph(cls) -> "JSONLDGraph":
    """Generate SHACL shapes graph from the classes in the ontology.

    Returns:
        JSONLDGraph: With _NodeShape and _PropertyShape (internal classes) instances.
    """

    # Collect unique entity types from the model
    entity_classes = cls._collect_entity_classes_from_model()

    # Generate node shapes
    shacl_shapes: List[_NodeShape] = []

    for entity_class in entity_classes:
        # Create node shape for this class
        node_shape = cls._create_node_shape(entity_class)
        shacl_shapes.append(node_shape)

    # Extract vocab from context
    vocab = cls.model_fields["context"].default.get(
        "@vocab", "http://example.com/vocab/"
    )

    # Build SHACL context
    shacl_context = {
        "@vocab": vocab,
        "@base": vocab,
        "sh": "http://www.w3.org/ns/shacl#",
        "xsd": "http://www.w3.org/2001/XMLSchema#",
    }

    # Return as JSONLDGraph
    return JSONLDGraph(context=shacl_context, graph=shacl_shapes)

Relation #

Bases: BaseModel

This class should be the type of Entity attributes for them to be considered as IRIs.

Parameters:

Name Type Description Default
id str

IRI of relation

required
Source code in pydontology/pydontology.py
11
12
13
14
15
16
17
18
19
class Relation(BaseModel):
    """This class should be the type of Entity attributes for them to be considered as IRIs.

    Args:
        id (str): IRI of relation
    """

    id: str = Field(alias="@id", title="@id", description="IRI (possibly relative)")
    model_config = ConfigDict(populate_by_name=True, serialize_by_alias=True)

make_model(ontology, name='Pydontology') #

Create a JSONLDGraph Pydantic model class

Parameters:

Name Type Description Default
ontology Union

Entity type or union of Entity types for the ontology.

required
name str

Name for the generated model class.

'Pydontology'

Returns:

Type Description
type[JSONLDGraph]

type[JSONLDGraph]: A Pydantic model class with the specified ontology.

Example::

from pydontology import Entity, make_model

class Person(Entity):
    name: str

class Employee(Person):
    title: str

ontology = Person | Employee
Model = make_model(ontology)
Source code in pydontology/pydontology.py
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
def make_model(ontology: type[Entity], name: str = "Pydontology") -> type[JSONLDGraph]:
    """Create a JSONLDGraph Pydantic model class

    Args:
        ontology (Union): Entity type or union of Entity types for the ontology.
        name (str): Name for the generated model class.

    Returns:
        type[JSONLDGraph]: A Pydantic model class with the specified ontology.

    Example::

        from pydontology import Entity, make_model

        class Person(Entity):
            name: str

        class Employee(Person):
            title: str

        ontology = Person | Employee
        Model = make_model(ontology)
    """

    return create_model(
        f"{name}",
        graph=(
            List[ontology],
            Field(
                alias="@graph",
                json_schema_extra={"name": "@graph", "description": "Default graph"},
            ),
        ),
        __base__=JSONLDGraph,
    )

Annotation classes#

These classes enable use of typing.Annotated to provide RDFS and SHACL metadata to attributes of the ontology classes, which is then used in the construction of the ontology graph and SHACL graph.

Not all RDFS or SHACL directives are supported currently. Contributions are welcome!

RDFSAnnotation #

Provides methods for setting RDFS annotations.

Encapsulates dataclasses that validate and provide type information for RDFS annotations. These annotations are used in the construction of the ontology graph.

Source code in pydontology/rdfs.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
class RDFSAnnotation:
    """Provides methods for setting RDFS annotations.

    Encapsulates dataclasses that validate and provide type information for RDFS annotations.
    These annotations are used in the construction of the ontology graph.
    """

    @dataclass
    class DOMAIN:
        """Dataclass that holds rdfs:domain annotation for a property.

        rdfs:domain is an instance of rdf:Property that is used to state that
        any resource that has a given property is an instance of one or more classes.

        Args:
            value (str): Name of RDFS class
        """

        value: Annotated[str, AfterValidator(val_no_whitespace)]

    @dataclass
    class RANGE:
        """Dataclass that holds rdfs:range annotation for a property.

        rdfs:range is an instance of rdf:Property that is used to state
        that the values of a property are instances of one or more classes.

        Args:
            value (str): Name of RDFS class
        """

        value: Annotated[str, AfterValidator(val_no_whitespace)]

    @staticmethod
    def domain(value: str) -> DOMAIN:
        """RDFSAnnotation.DOMAIN factory

        Args:
            value (str): Name of RDFS class

        Returns:
            RDFSAnnotation.DOMAIN
        """
        return RDFSAnnotation.DOMAIN(value=value)

    @staticmethod
    def range(value: str) -> RANGE:
        """RDFSAnnotation.RANGE factory

        Args:
            value (str): Name of RDFS class

        Returns:
            RDFSAnnotation.RANGE
        """
        return RDFSAnnotation.RANGE(value=value)

DOMAIN #

Dataclass that holds rdfs:domain annotation for a property.

rdfs:domain is an instance of rdf:Property that is used to state that any resource that has a given property is an instance of one or more classes.

Parameters:

Name Type Description Default
value str

Name of RDFS class

required
Source code in pydontology/rdfs.py
16
17
18
19
20
21
22
23
24
25
26
27
@dataclass
class DOMAIN:
    """Dataclass that holds rdfs:domain annotation for a property.

    rdfs:domain is an instance of rdf:Property that is used to state that
    any resource that has a given property is an instance of one or more classes.

    Args:
        value (str): Name of RDFS class
    """

    value: Annotated[str, AfterValidator(val_no_whitespace)]

RANGE #

Dataclass that holds rdfs:range annotation for a property.

rdfs:range is an instance of rdf:Property that is used to state that the values of a property are instances of one or more classes.

Parameters:

Name Type Description Default
value str

Name of RDFS class

required
Source code in pydontology/rdfs.py
29
30
31
32
33
34
35
36
37
38
39
40
@dataclass
class RANGE:
    """Dataclass that holds rdfs:range annotation for a property.

    rdfs:range is an instance of rdf:Property that is used to state
    that the values of a property are instances of one or more classes.

    Args:
        value (str): Name of RDFS class
    """

    value: Annotated[str, AfterValidator(val_no_whitespace)]

domain(value) staticmethod #

RDFSAnnotation.DOMAIN factory

Parameters:

Name Type Description Default
value str

Name of RDFS class

required

Returns:

Type Description
DOMAIN

RDFSAnnotation.DOMAIN

Source code in pydontology/rdfs.py
42
43
44
45
46
47
48
49
50
51
52
@staticmethod
def domain(value: str) -> DOMAIN:
    """RDFSAnnotation.DOMAIN factory

    Args:
        value (str): Name of RDFS class

    Returns:
        RDFSAnnotation.DOMAIN
    """
    return RDFSAnnotation.DOMAIN(value=value)

range(value) staticmethod #

RDFSAnnotation.RANGE factory

Parameters:

Name Type Description Default
value str

Name of RDFS class

required

Returns:

Type Description
RANGE

RDFSAnnotation.RANGE

Source code in pydontology/rdfs.py
54
55
56
57
58
59
60
61
62
63
64
@staticmethod
def range(value: str) -> RANGE:
    """RDFSAnnotation.RANGE factory

    Args:
        value (str): Name of RDFS class

    Returns:
        RDFSAnnotation.RANGE
    """
    return RDFSAnnotation.RANGE(value=value)

SHACLAnnotation #

Provides methods for setting SHACL annotations.

Encapsulates dataclasses that validate and provide type information for SHACL annotations. These annotations are used in the construction of the SHACL graph.

Source code in pydontology/shacl.py
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
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
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
class SHACLAnnotation:
    """Provides methods for setting SHACL annotations.

    Encapsulates dataclasses that validate and provide type information for SHACL annotations.
    These annotations are used in the construction of the SHACL graph.
    """

    @dataclass
    class DATATYPE:
        """Dataclass that holds sh:datatype annotation for a property.

        The values of sh:datatype in a shape are IRIs (e.g. xsd:integer).
        A shape has at most one value for sh:datatype.

        Args:
            value (str): IRI of datatype
        """

        value: Annotated[str, AfterValidator(val_datatype)]

    @dataclass
    class MAX_COUNT:
        """Dataclass that holds sh:maxCount annotation for a property.

        The maximum cardinality.
        The values of sh:maxCount in a property shape are literals with datatype xsd:integer.

        Args:
            value (int): Max cardinality of property
        """

        value: Annotated[int, AfterValidator(val_non_negative_int)]

    @dataclass
    class MIN_COUNT:
        """Dataclass that holds sh:minCount annotation for a property.

        The minimum cardinality.
        The values of sh:minCount in a property shape are literals with datatype xsd:integer.

        Args:
            value (int): Min cardinality of property
        """

        value: Annotated[int, AfterValidator(val_non_negative_int)]

    @dataclass
    class PATTERN:
        """Dataclass that holds sh:pattern annotation for a property.

        String-based constraint.
        A regular expression that all value nodes need to match.
        The values of sh:pattern in a shape are valid pattern arguments for the SPARQL REGEX function.

        Args:
            value (str): SPARQL regex (validation not implemented!)
        """

        value: Annotated[str, AfterValidator(val_regex_pattern)]

    @dataclass
    class MIN_LENGTH:
        """Dataclass that holds sh:minLength annotation for a property.

        String-based constraint.
        The minimum length. The values of sh:minLength in a shape are literals with datatype xsd:integer.
        A shape has at most one value for sh:minLength.

        Args:
            value (int): Min length of RDF literal
        """

        value: Annotated[int, AfterValidator(val_non_negative_int)]

    @dataclass
    class MAX_LENGTH:
        """Dataclass that holds sh:maxLength annotation for a property.

        String-based constraint.
        The maximum length. The values of sh:maxLength in a shape are literals with datatype xsd:integer.
        A shape has at most one value for sh:maxLength.

        Args:
            value (int): Max length of RDF literal
        """

        value: Annotated[int, AfterValidator(val_non_negative_int)]

    @dataclass
    class MIN_INCLUSIVE:
        """Dataclass that holds sh:minInclusive annotation for a property.

        Value range constraint.
        The minimum inclusive value. The values of sh:minInclusive in a shape are literals.
        A shape has at most one value for sh:minInclusive.

        Args:
            value (int | float): Min inclusive value of RDF literal
        """

        value: int | float

    @dataclass
    class MAX_INCLUSIVE:
        """Dataclass that holds sh:maxInclusive annotation for a property.

        Value range constraint.
        The maximum inclusive value. The values of sh:maxInclusive in a shape are literals.
        A shape has at most one value for sh:maxInclusive.

        Args:
            value (int | float): Max inclusive value of RDF literal
        """

        value: int | float

    @dataclass
    class MIN_EXCLUSIVE:
        """Dataclass that holds sh:minExclusive annotation for a property.

        Value range constraint.
        The minimum exclusive value. The values of sh:minExclusive in a shape are literals.
        A shape has at most one value for sh:minExclusive.

        Args:
            value (int | float): Min exclusive value of RDF literal
        """

        value: int | float

    @dataclass
    class MAX_EXCLUSIVE:
        """Dataclass that holds sh:maxExclusive annotation for a property.

        Value range constraint.
        The maximum exclusive value. The values of sh:maxExclusive in a shape are literals.
        A shape has at most one value for sh:maxExclusive.

        Args:
            value (int | float): Max exclusive value of RDF literal
        """

        value: int | float

    @dataclass
    class NODE_KIND:
        """Dataclass that holds sh:nodeKind annotation for a property.

        Value type constraint.
        The values of sh:nodeKind in a shape are one of the following six instances of the class sh:NodeKind:
        sh:BlankNode, sh:IRI, sh:Literal sh:BlankNodeOrIRI, sh:BlankNodeOrLiteral and sh:IRIOrLiteral.
        A shape has at most one value for sh:nodeKind.

        Args:
            value (str): Instance of node kind
        """

        value: Annotated[str, AfterValidator(val_node_kind)]

    @dataclass
    class CLASS:
        """Dataclass that holds sh:class annotation for a property.

        Value type constraint.
        The type of all value nodes. The values of sh:class in a shape are IRIs.

        Args:
            value (str): IRI of class
        """

        value: Annotated[str, AfterValidator(val_no_whitespace)]

    @staticmethod
    def datatype(value: str) -> DATATYPE:
        """SHACLAnnotation.DATATYPE factory

        Args:
            value (str): IRI of datatype

        Returns:
            SHACLAnnotation.DATATYPE
        """
        return SHACLAnnotation.DATATYPE(value)

    @staticmethod
    def maxCount(value: int) -> MAX_COUNT:
        """SHACLAnnotation.MAX_COUNT factory

        Args:
            value (int): Max cardinality of property

        Returns:
            SHACLAnnotation.MAX_COUNT
        """
        return SHACLAnnotation.MAX_COUNT(value)

    @staticmethod
    def minCount(value: int) -> MIN_COUNT:
        """SHACLAnnotation.MIN_COUNT factory

        Args:
            value (int): Min cardinality of property

        Returns:
            SHACLAnnotation.MIN_COUNT
        """
        return SHACLAnnotation.MIN_COUNT(value)

    @staticmethod
    def pattern(value: str) -> PATTERN:
        """SHACLAnnotation.PATTERN factory

        Args:
            value (str): SPARQL regex (validation not implemented!)

        Returns:
            SHACLAnnotation.PATTERN
        """
        return SHACLAnnotation.PATTERN(value)

    @staticmethod
    def minLength(value: int) -> MIN_LENGTH:
        """SHACLAnnotation.MIN_LENGTH factory

        Args:
            value (int): Min length of RDF literal

        Returns:
            SHACLAnnotation.MIN_LENGTH
        """
        return SHACLAnnotation.MIN_LENGTH(value)

    @staticmethod
    def maxLength(value: int) -> MAX_LENGTH:
        """SHACLAnnotation.MAX_LENGTH factory

        Args:
            value (int): Max length of RDF literal

        Returns:
            SHACLAnnotation.MAX_LENGTH
        """
        return SHACLAnnotation.MAX_LENGTH(value)

    @staticmethod
    def minInclusive(value: float) -> MIN_INCLUSIVE:
        """SHACLAnnotation.MIN_INCLUSIVE factory

        Args:
            value (int | float): Min inclusive value of RDF literal

        Returns:
            SHACLAnnotation.MIN_INCLUSIVE
        """
        return SHACLAnnotation.MIN_INCLUSIVE(value)

    @staticmethod
    def maxInclusive(value: float) -> MAX_INCLUSIVE:
        """SHACLAnnotation.MAX_INCLUSIVE factory

        Args:
            value (int | float): Max inclusive value of RDF literal

        Returns:
            SHACLAnnotation.MAX_INCLUSIVE
        """
        return SHACLAnnotation.MAX_INCLUSIVE(value)

    @staticmethod
    def minExclusive(value: float) -> MIN_EXCLUSIVE:
        """SHACLAnnotation.MIN_EXCLUSIVE factory

        Args:
            value (int | float): Min exclusive value of RDF literal

        Returns:
            SHACLAnnotation.MIN_EXCLUSIVE
        """
        return SHACLAnnotation.MIN_EXCLUSIVE(value)

    @staticmethod
    def maxExclusive(value: float) -> MAX_EXCLUSIVE:
        """SHACLAnnotation.MAX_EXCLUSIVE factory

        Args:
            value (int | float): Max exclusive value of RDF literal

        Returns:
            SHACLAnnotation.MAX_EXCLUSIVE
        """
        return SHACLAnnotation.MAX_EXCLUSIVE(value)

    @staticmethod
    def nodeKind(value: str) -> NODE_KIND:
        """SHACLAnnotation.NODE_KIND factory

        Args:
            value (str): Instance of node kind

        Returns:
            SHACLAnnotation.NODE_KIND
        """
        return SHACLAnnotation.NODE_KIND(value)

    @staticmethod
    def shclass(value: str) -> CLASS:
        """SHACLAnnotation.CLASS factory

        Args:
            value (str): IRI of class

        Returns:
            SHACLAnnotation.CLASS
        """
        return SHACLAnnotation.CLASS(value)

CLASS #

Dataclass that holds sh:class annotation for a property.

Value type constraint. The type of all value nodes. The values of sh:class in a shape are IRIs.

Parameters:

Name Type Description Default
value str

IRI of class

required
Source code in pydontology/shacl.py
174
175
176
177
178
179
180
181
182
183
184
185
@dataclass
class CLASS:
    """Dataclass that holds sh:class annotation for a property.

    Value type constraint.
    The type of all value nodes. The values of sh:class in a shape are IRIs.

    Args:
        value (str): IRI of class
    """

    value: Annotated[str, AfterValidator(val_no_whitespace)]

DATATYPE #

Dataclass that holds sh:datatype annotation for a property.

The values of sh:datatype in a shape are IRIs (e.g. xsd:integer). A shape has at most one value for sh:datatype.

Parameters:

Name Type Description Default
value str

IRI of datatype

required
Source code in pydontology/shacl.py
22
23
24
25
26
27
28
29
30
31
32
33
@dataclass
class DATATYPE:
    """Dataclass that holds sh:datatype annotation for a property.

    The values of sh:datatype in a shape are IRIs (e.g. xsd:integer).
    A shape has at most one value for sh:datatype.

    Args:
        value (str): IRI of datatype
    """

    value: Annotated[str, AfterValidator(val_datatype)]

MAX_COUNT #

Dataclass that holds sh:maxCount annotation for a property.

The maximum cardinality. The values of sh:maxCount in a property shape are literals with datatype xsd:integer.

Parameters:

Name Type Description Default
value int

Max cardinality of property

required
Source code in pydontology/shacl.py
35
36
37
38
39
40
41
42
43
44
45
46
@dataclass
class MAX_COUNT:
    """Dataclass that holds sh:maxCount annotation for a property.

    The maximum cardinality.
    The values of sh:maxCount in a property shape are literals with datatype xsd:integer.

    Args:
        value (int): Max cardinality of property
    """

    value: Annotated[int, AfterValidator(val_non_negative_int)]

MAX_EXCLUSIVE #

Dataclass that holds sh:maxExclusive annotation for a property.

Value range constraint. The maximum exclusive value. The values of sh:maxExclusive in a shape are literals. A shape has at most one value for sh:maxExclusive.

Parameters:

Name Type Description Default
value int | float

Max exclusive value of RDF literal

required
Source code in pydontology/shacl.py
145
146
147
148
149
150
151
152
153
154
155
156
157
@dataclass
class MAX_EXCLUSIVE:
    """Dataclass that holds sh:maxExclusive annotation for a property.

    Value range constraint.
    The maximum exclusive value. The values of sh:maxExclusive in a shape are literals.
    A shape has at most one value for sh:maxExclusive.

    Args:
        value (int | float): Max exclusive value of RDF literal
    """

    value: int | float

MAX_INCLUSIVE #

Dataclass that holds sh:maxInclusive annotation for a property.

Value range constraint. The maximum inclusive value. The values of sh:maxInclusive in a shape are literals. A shape has at most one value for sh:maxInclusive.

Parameters:

Name Type Description Default
value int | float

Max inclusive value of RDF literal

required
Source code in pydontology/shacl.py
117
118
119
120
121
122
123
124
125
126
127
128
129
@dataclass
class MAX_INCLUSIVE:
    """Dataclass that holds sh:maxInclusive annotation for a property.

    Value range constraint.
    The maximum inclusive value. The values of sh:maxInclusive in a shape are literals.
    A shape has at most one value for sh:maxInclusive.

    Args:
        value (int | float): Max inclusive value of RDF literal
    """

    value: int | float

MAX_LENGTH #

Dataclass that holds sh:maxLength annotation for a property.

String-based constraint. The maximum length. The values of sh:maxLength in a shape are literals with datatype xsd:integer. A shape has at most one value for sh:maxLength.

Parameters:

Name Type Description Default
value int

Max length of RDF literal

required
Source code in pydontology/shacl.py
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
@dataclass
class MAX_LENGTH:
    """Dataclass that holds sh:maxLength annotation for a property.

    String-based constraint.
    The maximum length. The values of sh:maxLength in a shape are literals with datatype xsd:integer.
    A shape has at most one value for sh:maxLength.

    Args:
        value (int): Max length of RDF literal
    """

    value: Annotated[int, AfterValidator(val_non_negative_int)]

MIN_COUNT #

Dataclass that holds sh:minCount annotation for a property.

The minimum cardinality. The values of sh:minCount in a property shape are literals with datatype xsd:integer.

Parameters:

Name Type Description Default
value int

Min cardinality of property

required
Source code in pydontology/shacl.py
48
49
50
51
52
53
54
55
56
57
58
59
@dataclass
class MIN_COUNT:
    """Dataclass that holds sh:minCount annotation for a property.

    The minimum cardinality.
    The values of sh:minCount in a property shape are literals with datatype xsd:integer.

    Args:
        value (int): Min cardinality of property
    """

    value: Annotated[int, AfterValidator(val_non_negative_int)]

MIN_EXCLUSIVE #

Dataclass that holds sh:minExclusive annotation for a property.

Value range constraint. The minimum exclusive value. The values of sh:minExclusive in a shape are literals. A shape has at most one value for sh:minExclusive.

Parameters:

Name Type Description Default
value int | float

Min exclusive value of RDF literal

required
Source code in pydontology/shacl.py
131
132
133
134
135
136
137
138
139
140
141
142
143
@dataclass
class MIN_EXCLUSIVE:
    """Dataclass that holds sh:minExclusive annotation for a property.

    Value range constraint.
    The minimum exclusive value. The values of sh:minExclusive in a shape are literals.
    A shape has at most one value for sh:minExclusive.

    Args:
        value (int | float): Min exclusive value of RDF literal
    """

    value: int | float

MIN_INCLUSIVE #

Dataclass that holds sh:minInclusive annotation for a property.

Value range constraint. The minimum inclusive value. The values of sh:minInclusive in a shape are literals. A shape has at most one value for sh:minInclusive.

Parameters:

Name Type Description Default
value int | float

Min inclusive value of RDF literal

required
Source code in pydontology/shacl.py
103
104
105
106
107
108
109
110
111
112
113
114
115
@dataclass
class MIN_INCLUSIVE:
    """Dataclass that holds sh:minInclusive annotation for a property.

    Value range constraint.
    The minimum inclusive value. The values of sh:minInclusive in a shape are literals.
    A shape has at most one value for sh:minInclusive.

    Args:
        value (int | float): Min inclusive value of RDF literal
    """

    value: int | float

MIN_LENGTH #

Dataclass that holds sh:minLength annotation for a property.

String-based constraint. The minimum length. The values of sh:minLength in a shape are literals with datatype xsd:integer. A shape has at most one value for sh:minLength.

Parameters:

Name Type Description Default
value int

Min length of RDF literal

required
Source code in pydontology/shacl.py
75
76
77
78
79
80
81
82
83
84
85
86
87
@dataclass
class MIN_LENGTH:
    """Dataclass that holds sh:minLength annotation for a property.

    String-based constraint.
    The minimum length. The values of sh:minLength in a shape are literals with datatype xsd:integer.
    A shape has at most one value for sh:minLength.

    Args:
        value (int): Min length of RDF literal
    """

    value: Annotated[int, AfterValidator(val_non_negative_int)]

NODE_KIND #

Dataclass that holds sh:nodeKind annotation for a property.

Value type constraint. The values of sh:nodeKind in a shape are one of the following six instances of the class sh:NodeKind: sh:BlankNode, sh:IRI, sh:Literal sh:BlankNodeOrIRI, sh:BlankNodeOrLiteral and sh:IRIOrLiteral. A shape has at most one value for sh:nodeKind.

Parameters:

Name Type Description Default
value str

Instance of node kind

required
Source code in pydontology/shacl.py
159
160
161
162
163
164
165
166
167
168
169
170
171
172
@dataclass
class NODE_KIND:
    """Dataclass that holds sh:nodeKind annotation for a property.

    Value type constraint.
    The values of sh:nodeKind in a shape are one of the following six instances of the class sh:NodeKind:
    sh:BlankNode, sh:IRI, sh:Literal sh:BlankNodeOrIRI, sh:BlankNodeOrLiteral and sh:IRIOrLiteral.
    A shape has at most one value for sh:nodeKind.

    Args:
        value (str): Instance of node kind
    """

    value: Annotated[str, AfterValidator(val_node_kind)]

PATTERN #

Dataclass that holds sh:pattern annotation for a property.

String-based constraint. A regular expression that all value nodes need to match. The values of sh:pattern in a shape are valid pattern arguments for the SPARQL REGEX function.

Parameters:

Name Type Description Default
value str

SPARQL regex (validation not implemented!)

required
Source code in pydontology/shacl.py
61
62
63
64
65
66
67
68
69
70
71
72
73
@dataclass
class PATTERN:
    """Dataclass that holds sh:pattern annotation for a property.

    String-based constraint.
    A regular expression that all value nodes need to match.
    The values of sh:pattern in a shape are valid pattern arguments for the SPARQL REGEX function.

    Args:
        value (str): SPARQL regex (validation not implemented!)
    """

    value: Annotated[str, AfterValidator(val_regex_pattern)]

datatype(value) staticmethod #

SHACLAnnotation.DATATYPE factory

Parameters:

Name Type Description Default
value str

IRI of datatype

required

Returns:

Type Description
DATATYPE

SHACLAnnotation.DATATYPE

Source code in pydontology/shacl.py
187
188
189
190
191
192
193
194
195
196
197
@staticmethod
def datatype(value: str) -> DATATYPE:
    """SHACLAnnotation.DATATYPE factory

    Args:
        value (str): IRI of datatype

    Returns:
        SHACLAnnotation.DATATYPE
    """
    return SHACLAnnotation.DATATYPE(value)

maxCount(value) staticmethod #

SHACLAnnotation.MAX_COUNT factory

Parameters:

Name Type Description Default
value int

Max cardinality of property

required

Returns:

Type Description
MAX_COUNT

SHACLAnnotation.MAX_COUNT

Source code in pydontology/shacl.py
199
200
201
202
203
204
205
206
207
208
209
@staticmethod
def maxCount(value: int) -> MAX_COUNT:
    """SHACLAnnotation.MAX_COUNT factory

    Args:
        value (int): Max cardinality of property

    Returns:
        SHACLAnnotation.MAX_COUNT
    """
    return SHACLAnnotation.MAX_COUNT(value)

maxExclusive(value) staticmethod #

SHACLAnnotation.MAX_EXCLUSIVE factory

Parameters:

Name Type Description Default
value int | float

Max exclusive value of RDF literal

required

Returns:

Type Description
MAX_EXCLUSIVE

SHACLAnnotation.MAX_EXCLUSIVE

Source code in pydontology/shacl.py
295
296
297
298
299
300
301
302
303
304
305
@staticmethod
def maxExclusive(value: float) -> MAX_EXCLUSIVE:
    """SHACLAnnotation.MAX_EXCLUSIVE factory

    Args:
        value (int | float): Max exclusive value of RDF literal

    Returns:
        SHACLAnnotation.MAX_EXCLUSIVE
    """
    return SHACLAnnotation.MAX_EXCLUSIVE(value)

maxInclusive(value) staticmethod #

SHACLAnnotation.MAX_INCLUSIVE factory

Parameters:

Name Type Description Default
value int | float

Max inclusive value of RDF literal

required

Returns:

Type Description
MAX_INCLUSIVE

SHACLAnnotation.MAX_INCLUSIVE

Source code in pydontology/shacl.py
271
272
273
274
275
276
277
278
279
280
281
@staticmethod
def maxInclusive(value: float) -> MAX_INCLUSIVE:
    """SHACLAnnotation.MAX_INCLUSIVE factory

    Args:
        value (int | float): Max inclusive value of RDF literal

    Returns:
        SHACLAnnotation.MAX_INCLUSIVE
    """
    return SHACLAnnotation.MAX_INCLUSIVE(value)

maxLength(value) staticmethod #

SHACLAnnotation.MAX_LENGTH factory

Parameters:

Name Type Description Default
value int

Max length of RDF literal

required

Returns:

Type Description
MAX_LENGTH

SHACLAnnotation.MAX_LENGTH

Source code in pydontology/shacl.py
247
248
249
250
251
252
253
254
255
256
257
@staticmethod
def maxLength(value: int) -> MAX_LENGTH:
    """SHACLAnnotation.MAX_LENGTH factory

    Args:
        value (int): Max length of RDF literal

    Returns:
        SHACLAnnotation.MAX_LENGTH
    """
    return SHACLAnnotation.MAX_LENGTH(value)

minCount(value) staticmethod #

SHACLAnnotation.MIN_COUNT factory

Parameters:

Name Type Description Default
value int

Min cardinality of property

required

Returns:

Type Description
MIN_COUNT

SHACLAnnotation.MIN_COUNT

Source code in pydontology/shacl.py
211
212
213
214
215
216
217
218
219
220
221
@staticmethod
def minCount(value: int) -> MIN_COUNT:
    """SHACLAnnotation.MIN_COUNT factory

    Args:
        value (int): Min cardinality of property

    Returns:
        SHACLAnnotation.MIN_COUNT
    """
    return SHACLAnnotation.MIN_COUNT(value)

minExclusive(value) staticmethod #

SHACLAnnotation.MIN_EXCLUSIVE factory

Parameters:

Name Type Description Default
value int | float

Min exclusive value of RDF literal

required

Returns:

Type Description
MIN_EXCLUSIVE

SHACLAnnotation.MIN_EXCLUSIVE

Source code in pydontology/shacl.py
283
284
285
286
287
288
289
290
291
292
293
@staticmethod
def minExclusive(value: float) -> MIN_EXCLUSIVE:
    """SHACLAnnotation.MIN_EXCLUSIVE factory

    Args:
        value (int | float): Min exclusive value of RDF literal

    Returns:
        SHACLAnnotation.MIN_EXCLUSIVE
    """
    return SHACLAnnotation.MIN_EXCLUSIVE(value)

minInclusive(value) staticmethod #

SHACLAnnotation.MIN_INCLUSIVE factory

Parameters:

Name Type Description Default
value int | float

Min inclusive value of RDF literal

required

Returns:

Type Description
MIN_INCLUSIVE

SHACLAnnotation.MIN_INCLUSIVE

Source code in pydontology/shacl.py
259
260
261
262
263
264
265
266
267
268
269
@staticmethod
def minInclusive(value: float) -> MIN_INCLUSIVE:
    """SHACLAnnotation.MIN_INCLUSIVE factory

    Args:
        value (int | float): Min inclusive value of RDF literal

    Returns:
        SHACLAnnotation.MIN_INCLUSIVE
    """
    return SHACLAnnotation.MIN_INCLUSIVE(value)

minLength(value) staticmethod #

SHACLAnnotation.MIN_LENGTH factory

Parameters:

Name Type Description Default
value int

Min length of RDF literal

required

Returns:

Type Description
MIN_LENGTH

SHACLAnnotation.MIN_LENGTH

Source code in pydontology/shacl.py
235
236
237
238
239
240
241
242
243
244
245
@staticmethod
def minLength(value: int) -> MIN_LENGTH:
    """SHACLAnnotation.MIN_LENGTH factory

    Args:
        value (int): Min length of RDF literal

    Returns:
        SHACLAnnotation.MIN_LENGTH
    """
    return SHACLAnnotation.MIN_LENGTH(value)

nodeKind(value) staticmethod #

SHACLAnnotation.NODE_KIND factory

Parameters:

Name Type Description Default
value str

Instance of node kind

required

Returns:

Type Description
NODE_KIND

SHACLAnnotation.NODE_KIND

Source code in pydontology/shacl.py
307
308
309
310
311
312
313
314
315
316
317
@staticmethod
def nodeKind(value: str) -> NODE_KIND:
    """SHACLAnnotation.NODE_KIND factory

    Args:
        value (str): Instance of node kind

    Returns:
        SHACLAnnotation.NODE_KIND
    """
    return SHACLAnnotation.NODE_KIND(value)

pattern(value) staticmethod #

SHACLAnnotation.PATTERN factory

Parameters:

Name Type Description Default
value str

SPARQL regex (validation not implemented!)

required

Returns:

Type Description
PATTERN

SHACLAnnotation.PATTERN

Source code in pydontology/shacl.py
223
224
225
226
227
228
229
230
231
232
233
@staticmethod
def pattern(value: str) -> PATTERN:
    """SHACLAnnotation.PATTERN factory

    Args:
        value (str): SPARQL regex (validation not implemented!)

    Returns:
        SHACLAnnotation.PATTERN
    """
    return SHACLAnnotation.PATTERN(value)

shclass(value) staticmethod #

SHACLAnnotation.CLASS factory

Parameters:

Name Type Description Default
value str

IRI of class

required

Returns:

Type Description
CLASS

SHACLAnnotation.CLASS

Source code in pydontology/shacl.py
319
320
321
322
323
324
325
326
327
328
329
@staticmethod
def shclass(value: str) -> CLASS:
    """SHACLAnnotation.CLASS factory

    Args:
        value (str): IRI of class

    Returns:
        SHACLAnnotation.CLASS
    """
    return SHACLAnnotation.CLASS(value)