mowl.ontology
Ontology creation
- mowl.ontology.create.create_from_triples(triples_file, out_file, relation_name=None, bidirectional=False, head_prefix='', tail_prefix='')[source]
Method to create an ontology from a .tsv file with triples.
- Parameters:
triples_file (str) – Path for the file containing the triples. This file must be a .tsv file and each row must be of the form (head, relation, tail). It is also supported .tsv files with rows of the form (head, tail); in that case the field relation_name must be specified.
out_file (str) – Path for the output ontology file.
relation_name (str, optional) – Name for relation in case the .tsv input file has only two columns. Defaults to
None
.bidirectional (bool, optional) – If True, the triples will be considered undirected. Defaults to
False
head_prefix (str, optional) – Prefix to be assigned to the head of each triple. Default is
""
.tail_prefix (str, optional) – Prefix to be assigned to the tail of each triple. Default is
""
.
Ontology extension
- mowl.ontology.extend.insert_annotations(ontology_file, annotations, out_file=None, verbose=False)[source]
Method to build dataset given an ontology file and the annotations to be inserted to the ontology. Annotation files must be in .tsv format, with no header. Per each row, the first element is the annotated entity and the rest of the elements are the annotating entities (which are the entities in the ontology).
- Parameters:
ontology_file (str) – Ontology file in .owl format
annotations (List of (str, str, bool) corresponding to (annotation file path, relation name, directed or undirected graph)) – Annotations to be included in the ontology. There can be more than one annotation file.
out_file (str, optional) – Path for the new ontology. Defaults to
ontology_file
verbose (bool) – If true, information is shown.”
EL Normalization
- class mowl.ontology.normalize.ELNormalizer[source]
Bases:
object
This class wraps the normalization functionality found in the Java library
Jcel
. The normalization process transforms an ontology into 7 normal forms in the description logic EL language.- normalize(ontology, load=False)[source]
Performs the normalization. :param ontology: Input ontology :type ontology:
org.semanticweb.owlapi.model.OWLOntology
:param load: Load the GCIs if the ontology is already normalized. Default is False. :type load: bool, optional- Return type:
Dictionary where the keys are labels for each normal form and the values are a list of axioms of each normal form.
- class mowl.ontology.normalize.Axiom(axiom)[source]
Bases:
object
Base class for all axioms in the \(\mathcal{EL}\) language
- property owl_axiom
Returns the axiom
- Return type:
org.semanticweb.owlapi.model.OWLAxiom
- class mowl.ontology.normalize.GCI(axiom)[source]
Bases:
Axiom
Base class for all GCI types in the \(\mathcal{EL}\) language
- property owl_subclass
Returns the subclass of the GCI
- Return type:
org.semanticweb.owlapi.model.OWLClassExpression
- property owl_superclass
Returns the superclass of the GCI
- Return type:
org.semanticweb.owlapi.model.OWLClassExpression
- class mowl.ontology.normalize.ClassAssertion(axiom)[source]
Bases:
Axiom
Class assertion axiom of the form \(A(a)\) :param axiom: Axiom of the form \(A(a)\) :type axiom:
org.semanticweb.owlapi.model.OWLAxiom
- property class_
Returns the class of the class assertion
- Return type:
org.semanticweb.owlapi.model.OWLClass
- property individual
Returns the individual of the class assertion
- Return type:
org.semanticweb.owlapi.model.OWLNamedIndividual
- class mowl.ontology.normalize.ObjectPropertyAssertion(axiom)[source]
Bases:
Axiom
Object property assertion axiom of the form \(R(a,b)\) :param axiom: Axiom of the form \(R(a,b)\) :type axiom:
org.semanticweb.owlapi.model.OWLAxiom
- property object_property
Returns the object property of the object property assertion
- Return type:
org.semanticweb.owlapi.model.OWLObjectProperty
- property subject
Returns the subject of the object property assertion
- Return type:
org.semanticweb.owlapi.model.OWLNamedIndividual
- property object_
Returns the object of the object property assertion
- Return type:
org.semanticweb.owlapi.model.OWLNamedIndividual
- class mowl.ontology.normalize.GCI0(axiom)[source]
Bases:
GCI
GCI of the form \(C \sqsubseteq D\)
- Parameters:
axiom (
org.semanticweb.owlapi.model.OWLAxiom
) – Axiom of the form \(C \sqsubseteq D\)
- property subclass
Returns the subclass of the GCI: \(C\)
- Return type:
org.semanticweb.owlapi.model.OWLClass
- property superclass
” Returns the superclass of the GCI: \(D\) or \(\bot\)
- Return type:
org.semanticweb.owlapi.model.OWLClass
- class mowl.ontology.normalize.GCI0_BOT(axiom)[source]
Bases:
GCI0
GCI of the form \(C \sqsubseteq \bot\)
- Parameters:
axiom (
org.semanticweb.owlapi.model.OWLAxiom
) – Axiom of the form \(C \sqsubseteq \bot\)
- class mowl.ontology.normalize.GCI1(axiom)[source]
Bases:
GCI
GCI of the form \(C \sqcap D \sqsubseteq E\)
- Parameters:
axiom (
org.semanticweb.owlapi.model.OWLAxiom
) – Axiom of the form \(C \sqcap D \sqsubseteq E\)
- property left_subclass
” Returns the left operand of the subclass of the GCI: \(C\)
- Return type:
org.semanticweb.owlapi.model.OWLClass
- property right_subclass
Returns the right operand of the subclass of the GCI: \(D\)
- Return type:
org.semanticweb.owlapi.model.OWLClass
- property superclass
Returns the superclass of the GCI: \(E\) or \(\bot\)
- Return type:
org.semanticweb.owlapi.model.OWLClass
- class mowl.ontology.normalize.GCI1_BOT(axiom)[source]
Bases:
GCI1
GCI of the form \(C \sqcap D \sqsubseteq \bot\)
- Parameters:
axiom (
org.semanticweb.owlapi.model.OWLAxiom
) – Axiom of the form \(C \sqcap D \sqsubseteq \bot\)
- class mowl.ontology.normalize.GCI2(axiom)[source]
Bases:
GCI
GCI of the form \(C \sqsubseteq \exists R.D\)
- Parameters:
axiom (
org.semanticweb.owlapi.model.OWLAxiom
) – Axiom of the form \(C \sqsubseteq \exists R.D\)
- property subclass
Returns the subclass of the GCI: \(C\)
- Return type:
org.semanticweb.owlapi.model.OWLClass
- property object_property
Returns the object property of the GCI: \(R\)
- Return type:
org.semanticweb.owlapi.model.OWLObjectProperty
- property filler
Returns the filler of the GCI: \(D\)
- Return type:
org.semanticweb.owlapi.model.OWLClass
- class mowl.ontology.normalize.GCI3(axiom)[source]
Bases:
GCI
GCI of the form \(\exists R.C \sqsubseteq D\)
- Parameters:
axiom (
org.semanticweb.owlapi.model.OWLAxiom
) – Axiom of the form \(\exists R.C \sqsubseteq D\)
- property object_property
Returns the object property of the GCI: \(R\)
- Return type:
org.semanticweb.owlapi.model.OWLObjectProperty
- property filler
Returns the filler of the GCI: \(C\)
- Return type:
org.semanticweb.owlapi.model.OWLClass
- property superclass
Returns the superclass of the GCI: \(D\) or \(\bot\)
- Return type:
org.semanticweb.owlapi.model.OWLClass