Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Artefact: the result of reading

The Artefact is the hand-over between the reader and everything after it. It holds the entities, the RDF graph, the IRI of the documented artefact, the imported modules, the warnings and the format. Viewers, the builder and the API depend on this object only: they never need the reader that built it.

This notebook inspects an artefact, read from a small ontology.

Methods to inspect an artefact

MethodWhat it gives
OwlOntology(source), lode.read(source, read_as)Read a source. Both return an Artefact.
artefact.read_asThe name of the format the artefact was read as.
artefact.get_entities(cls=None)The entities, as a list; with a model class, only those of that class and its subclasses.
artefact.get_entities_by_iri(iri)The entities registered under an IRI, or None.
artefact.entitiesThe dictionary behind the two methods above: IRI to set of entities. It also holds the literals.
artefact.artefact_iri, artefact.artefact_base_iriThe IRI of the documented ontology or vocabulary, and its namespace.
artefact.graph, artefact.main_graph()The RDF graph, and only the triples of the loaded artefact.
artefact.imported_urisThe IRIs of the modules pulled in by imports.
artefact.warningsThe reader warnings, when requested.
artefact.provenance(entity)The triples an entity was built from.
artefact.profile, artefact.readerThe profile of the format, and the reader that built the artefact.

Examples

One for each method of the table, on a small ontology.

OwlOntology(source) and lode.read(source, read_as)

OwlOntology OwlOntology

artefact.read_as

owl

artefact.get_entities(cls=None)

Literals are values, not entities, and are never listed.

{'Concept': 3, 'Model': 1, 'Datatype': 1}
[Concept('http://example.org/zoo#Cat'), Concept('http://example.org/zoo#Animal'), Concept('http://www.w3.org/2002/07/owl#Thing'), Datatype('http://www.w3.org/2000/01/rdf-schema#Literal')]

artefact.get_entities_by_iri(iri)

A set, because one IRI can be used for more than one kind of entity (punning).

{Concept('http://example.org/zoo#Cat')}

artefact.entities

The dictionary behind get_entities. Treat it as read-only: the reader shares it with the artefact.

8 keys
LITERAL::Animal@en^^
LITERAL::Cat@en^^
LITERAL::Zoo@en^^
http://example.org/zoo
http://example.org/zoo#Animal

artefact.artefact_iri and artefact.artefact_base_iri

http://example.org/zoo
http://example.org/

artefact.graph and artefact.main_graph()

They are the same graph here. With imports requested, graph also holds the imported modules and main_graph() keeps only the triples of the loaded artefact.

7 7

artefact.imported_uris

set()

artefact.warnings

Empty unless the artefact is read with warnings=True.

[] []

artefact.provenance(entity)

Computed only when asked for, because most entities are never inspected.

@prefix ns1: <http://www.w3.org/2000/01/rdf-schema#> .

<http://example.org/zoo#Cat> a <http://www.w3.org/2002/07/owl#Class> ;
    ns1:label "Cat"@en ;
    ns1:subClassOf <http://example.org/zoo#Animal> .


artefact.profile and artefact.reader

owl
OwlReader

How LODE uses it

The reader fills the artefact once, and everything after it reads from there: the viewer, the static builder and the API. Reading is described in the Python API.

Writing your own artefact class

This page only inspects the artefact. The Artefact class of a format carries no code: a subclass that the profile names, so that users can read the format with MyFormat(path). To write it, go to Extending LODE, the artefact class.