Module horned_owl::model
source · Expand description
This module implements the basic data data structure for OWL2.
Overview
This module consists of a core data model, most of which are concrete implementations.
An Ontology
is represented with an interface similar to a
HashSet
but using a trait. No methods are provided to search or
access the contents of an Ontology
which are instead provided by
implementations. Each Ontology
is a set of
AnnotatedAxiom
instances, which consists of an Axiom
and a set
of Annotation
. The Axiom
itself is a large enum representing
the different axioms that OWL2 supports.
Efficiency is gained from the use of an IRI which is a newtype
over an Rc<String>
.
Naming
The OWL specification is large and complicated. This library, therefore, takes efforts to be as regular and predictable as possible. Names have been chosen to reflect the OWL structural specification, (see https://www.w3.org/TR/owl2-syntax/).
The core data structures use both C-style structs and tuples structs. The aim is for this to maximize usability. The rules are as follows:
- Use tuples where all the entities are of the same type and semantically equivalent
- Use structs where entities are not equivalent.
- Where values are equivalent and bounded in number to two, use a tuple with two values.
- Where values are equivalent, but unbounded, use a Vec, either as part of a tuple or struct.
- Where structs are used, variables names should be short, identify the type is unique, or be descriptive if not.
Example
- Rule 1:
// TransitiveObjectProperty(ObjectProperty)
let b = Build::new_rc();
let top = TransitiveObjectProperty(ObjectPropertyExpression::ObjectProperty
(b.object_property("http://www.example.com/op")));
- Rule 2:
// ObjectSomeValuesFrom{ope:PropertyExpression, ce:ClassExpression}
let b = Build::new_rc();
let some = ClassExpression::ObjectSomeValuesFrom{
ope: b.object_property("http://www.example.com/p").into(),
bce: b.class("http://www.example.com/c").into()
};
- Rule 3:
// InverseObjectProperty(ObjectProperty, ObjectProperty)
let b = Build::new_rc();
let iop = InverseObjectProperties
(b.object_property("http://www.example.com/op1"),
b.object_property("http://www.example.com/op2"));
- Rule 4:
// EquivalentClasses(Vec<ClassExpression>)
let b = Build::new_rc();
let ec = EquivalentClasses
(vec!(b.class("http://www.example.com/op1").into(),
b.class("http://www.example.com/op2").into()));
- Rule 5:
//ObjectPropertyAssertion {
//ope: ObjectPropertyExpression,
//from: Individual,
//to: Individual,
//}
let b = Build::new_rc();
let opa = ObjectPropertyAssertion {
ope: b.object_property("http://www.example.com/op").into(),
from: b.named_individual("http://www.example.com/i1").into(),
to: b.named_individual("http://www.example.com/i2").into(),
};
Structs
AnnotatedAxiom
is an Axiom
with one orpmore Annotation
.Annotation
.AnnotationProperty
AnnotationProperty
Build
creates new IRI
and NamedEntity
instances.ClassExpression
ClassExpression
and
a set of others.ClassExpression
.ClassExpression
.Enums
Traits
AxiomKind
MutableOntology
OntologyID
of an Ontology