ontolutils.classes.thing.Thing

class ontolutils.classes.thing.Thing(*, id: ~typing.Optional[object] = <factory>, label: ~typing.Optional[~typing.Union[str, ~ontolutils.classes.thing.LangString, ~typing.List[~typing.Union[str, ~ontolutils.classes.thing.LangString]]]] = None, alt_label: ~typing.Optional[~typing.Union[str, ~ontolutils.classes.thing.LangString, ~typing.List[~typing.Union[str, ~ontolutils.classes.thing.LangString]]]] = None, broader: ~typing.Optional[~typing.Union[object, ~ontolutils.classes.thing.Thing, ~typing.List[~typing.Union[object, ~ontolutils.classes.thing.Thing]]]] = None, comment: ~typing.Optional[~typing.Union[str, ~ontolutils.classes.thing.LangString, ~typing.List[~typing.Union[str, ~ontolutils.classes.thing.LangString]]]] = None, about: ~typing.Optional[~typing.Union[object, ~ontolutils.classes.thing.Thing, ~typing.List[~typing.Union[object, ~ontolutils.classes.thing.Thing]]]] = None, relation: ~typing.Optional[~typing.Union[object, ~ontolutils.classes.thing.Thing, ~typing.List[~typing.Union[object, ~ontolutils.classes.thing.Thing]]]] = None, close_match: ~typing.Optional[~typing.Union[object, ~ontolutils.classes.thing.Thing, ~typing.List[~typing.Union[object, ~ontolutils.classes.thing.Thing]]]] = None, exact_match: ~typing.Optional[~typing.Union[object, ~ontolutils.classes.thing.Thing, ~typing.List[~typing.Union[object, ~ontolutils.classes.thing.Thing]]]] = None, description: ~typing.Optional[~typing.Union[str, ~ontolutils.classes.thing.LangString, ~typing.List[~typing.Union[str, ~ontolutils.classes.thing.LangString]]]] = None, is_defined_by: ~typing.Optional[~typing.Union[object, ~ontolutils.classes.thing.Thing, ~typing.List[~typing.Union[object, ~ontolutils.classes.thing.Thing]]]] = None, **extra_data: ~typing.Any)

Most basic concept class owl:Thing (see also https://www.w3.org/TR/owl-guide/)

This class is basis to model other concepts.

Example for prov:Person:

>>> @namespaces(prov='https://www.w3.org/ns/prov#',
>>>             foaf='http://xmlns.com/foaf/0.1/')
>>> @urirefs(Person='prov:Person', first_name='foaf:firstName')
>>> class Person(Thing):
>>>     first_name: str = None
>>>     last_name: str = None
>>> p = Person(first_name='John', last_name='Doe', age=30)
>>> # Note, that age is not defined in the class! This is allowed, but may not be
>>> # serialized into an IRI although the ontology defines it
>>> print(p.model_dump_jsonld())
>>> {
>>>     "@context": {
>>>         "prov": "https://www.w3.org/ns/prov#",
>>>         "foaf": "http://xmlns.com/foaf/0.1/",
>>>         "first_name": "foaf:firstName"
>>>     },
>>>     "@id": "N23036f1a4eb149edb7db41b2f5f4268c",
>>>     "@type": "prov:Person",
>>>     "foaf:firstName": "John",
>>>     "last_name": "Doe",
>>>     "age": "30"  # Age appears as a field without context!
>>> }

Note, that values are validated, as Thing is a subclass of pydantic.BaseModel:

>>> Person(first_name=1)

Will lead to a validation error:

>>> # Traceback (most recent call last):
>>> # ...
>>> # pydantic_core._pydantic_core.ValidationError: 1 validation error for Person
>>> # first_name
>>> #   Input should be a valid string [type=string_type, input_value=1, input_type=int]
>>> #     For further information visit https://errors.pydantic.dev/2.4/v/string_type
__init__(**data: Any) None

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Methods

__init__(**data)

Create a new model by parsing and validating input data from keyword arguments.

add_property(*, name, property_type, ...[, ...])

Add a property to the class

build(namespace, namespace_prefix, ...)

Build a Thing object

construct([_fields_set])

copy(*[, include, exclude, update, deep])

Returns a copy of the model.

create_query([select_vars, subject, limit, ...])

Generate a SPARQL query to find instances of this Thing subclass.

dict(*[, include, exclude, by_alias, ...])

from_file([source, format, limit, context])

Initialize the class from a file

from_graph(graph[, subject, limit, distinct])

Initialize the class from an rdflib Graph for a given subject.

from_jsonld([source, data, limit, context])

Initialize the class from a JSON-LD source

from_orm(obj)

from_sparql(sparql_result[, raise_on_error])

Initialize the class from a SPARQL result

from_ttl([source, data, limit, context])

Initialize the class from a Turtle source

get_alt_label([pref_lang])

get_context()

Return the context of the class

get_iri(item)

get_jsonld_dict([base_uri, context, ...])

Return the JSON-LD dictionary of the object.

get_label([pref_lang])

iri([key, compact])

Return the IRI of the class or the key

json(*[, include, exclude, by_alias, ...])

map(other)

Return the class as another class.

model_construct([_fields_set])

Creates a new instance of the Model class with validated data.

model_copy(*[, update, deep])

!!! abstract "Usage Documentation"

model_dump(*[, mode, include, exclude, ...])

!!! abstract "Usage Documentation"

model_dump_json(*[, indent, ensure_ascii, ...])

!!! abstract "Usage Documentation"

model_dump_jsonld([context, exclude_none, ...])

Similar to model_dump_json() but will return a JSON string with context resulting in a JSON-LD serialization.

model_dump_ttl([context, exclude_none, ...])

Dump the model as a Turtle string.

model_json_schema([by_alias, ref_template, ...])

Generates a JSON schema for a model class.

model_parametrized_name(params)

Compute the class name for parametrizations of generic classes.

model_post_init(context, /)

Override this method to perform additional initialization after __init__ and model_construct.

model_rebuild(*[, force, raise_errors, ...])

Try to rebuild the pydantic-core schema for the model.

model_validate(obj, *[, strict, extra, ...])

Validate a pydantic model instance.

model_validate_json(json_data, *[, strict, ...])

!!! abstract "Usage Documentation"

model_validate_strings(obj, *[, strict, ...])

Validate the given object with string data against the Pydantic model.

parse_file(path, *[, content_type, ...])

parse_obj(obj)

parse_raw(b, *[, content_type, encoding, ...])

schema([by_alias, ref_template])

schema_json(*[, by_alias, ref_template])

serialize(format[, context, exclude_none, ...])

Serialize the object to a given format. This method calls rdflib.Graph().parse(), so the available formats are the same as for the rdflib library: "xml", "n3", "turtle", "nt", "pretty-xml", "trix", "trig", "nquads", "json-ld" and "hext" are built in. The kwargs are passed to rdflib.Graph().parse().

update_forward_refs(**localns)

validate([shacl_source, shacl_data, ...])

Attributes

model_computed_fields

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_extra

Get extra fields set during validation.

model_fields

model_fields_set

Returns the set of fields that have been explicitly set on this model instance.

namespace

namespaces

Return the namespaces of the class

uri

urirefs

Return the urirefs of the class

id

label

altLabel

broader

comment

about

relation

closeMatch

exactMatch

description

isDefinedBy