Class OWLAPILiteFactory
java.lang.Object
io.github.kodymoodley.owlapilite.OWLAPILiteFactory
Core class for OWLAPI-Lite which provides access to all methods for
constructing and editing OWL ontologies.
- Version:
- 1.0.1
- Author:
- Kody Moodley, https://kodymoodley.github.io
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.semanticweb.owlapi.model.OWLAxiomMakes all the individual names in the ontology refer to different individuals (simulate the unique name assumption)org.semanticweb.owlapi.model.OWLAxiomcreateAxiom(String axiomStr) Creates a new OWLAxiom, adds this axiom to the currently selected ontology, and prints out the axiom to the consolevoidcreateClass(String classname) Creates a new class name, adds this class to the parser's vocabulary and the currently selected ontology, and prints out the class to the consolevoidcreateClasses(String classnames) Creates multiple class names, adds them to the parser vocabulary and the currently selected ontologyorg.semanticweb.owlapi.model.OWLClassExpressioncreateClassExpression(String classExpressionStr) Creates an anonymous class expression and prints out the class expression to the consolevoidcreateDataProperties(String dpropsstr) Creates multiple data properties, adds them to the parser vocabulary and the currently selected ontologyvoidcreateDataProperty(String dpropname) Creates a new data property, adds this data property to the parser's vocabulary and the currently selected ontology, and prints out the data property to the consolevoidcreateDProperties(String dpropsstr) Alias for createDataProperties method.voidcreateDProperty(String dpropname) Alias for createDataProperty method.voidcreateIndividual(String individualname) Creates a new individual name, adds this individual name to the parser's vocabulary and the currently selected ontology, and prints out the individual name to the consolevoidcreateIndividuals(String indnames) Creates multiple individual names, adds them to the parser vocabulary and the currently selected ontologyvoidcreateObjectProperties(String opropsstr) Creates multiple object properties, adds them to the parser vocabulary and the currently selected ontologyvoidcreateObjectProperty(String opropname) Creates a new object property, adds this object property to the parser's vocabulary and the currently selected ontology, and prints out the object property to the consolevoidcreateObjectProperty(String opropname, int trans, int ref, int sym) Creates a new object property, adds this object property to the parser's vocabulary and the currently selected ontology, and prints out the object property to the consoleorg.semanticweb.owlapi.model.OWLAxiomcreateObjectPropertyAssertion(String axiomStr) Creates role axiom from stringorg.semanticweb.owlapi.model.OWLOntologycreateOntology(String iriStr) Creates a new OWL ontology given a string representation of an IRIvoidcreateOProperties(String opropsstr) Alias for createObjectProperties method.voidcreateOProperty(String opropname) Alias for createObjectProperty method.voidcreateOProperty(String opropname, int trans, int ref, int sym) Alias for createOProperty method Creates a new object property, adds this object property to the parser's vocabulary and the currently selected ontology, and prints out the object property to the consoleorg.semanticweb.owlapi.model.OWLAxiomcreateOPropertyAssertion(String axiomStr) Alias for createObjectPropertyAssertion methodorg.semanticweb.owlapi.model.OWLAxiomdifferentIndividuals(String differentIndividualsStr) Makes the specified individual names in the ontology refer to different individuals (simulate the unique name assumption for a subset of individual names)static OWLAPILiteFactoryStatic method to get hold of a OWLAPILiteFactory instancestatic OWLAPILiteFactorygetInstance(SelectedReasoner selectedReasoner) Static method to get hold of a OWLAPILiteFactory instancevoidPrints the IRI strings of each ontology that has been created so far using this instance of OWLAPILiteFactoryorg.semanticweb.owlapi.model.OWLOntologyPrints the IRI string of the currently selected ontologyorg.semanticweb.owlapi.model.OWLOntologyloadFromFile(String filepath) Loads an OWL ontology from local file into the OWLAPILiteFactory instance.org.semanticweb.owlapi.model.OWLOntologyloadFromURL(String url) Loads an OWL ontology from a remote URL into the OWLAPILiteFactory instance.voidmakeAntiSymmetric(String opropname) Makes an existing object property in the ontology asymmetricvoidmakeIRReflexive(String opropname) Makes an existing object property in the ontology irreflexivevoidmakeReflexive(String opropname) Makes an existing object property in the ontology reflexivevoidmakeSymmetric(String opropname) Makes an existing object property in the ontology symmetricvoidmakeTransitive(String opropname) Makes an existing object property in the ontology transitivevoidprint(org.semanticweb.owlapi.model.OWLAxiom axiom) Prints an OWLAxiom object to console outputvoidPrints a grouped list of the main logical entities in the ontology to console (classes, properties, individuals, TBox, ABox, RBox etc.)voidPrints OWLOntology metrics to console output e.g.voidremoveAxiom(String axiomStr) Removes axiom from the currently selected ontologyvoidremoveAxiom(org.semanticweb.owlapi.model.OWLAxiom a) Removes axiom from the currently selected ontologyvoidremoveAxioms(Set<org.semanticweb.owlapi.model.OWLAxiom> a) Removes a set of axioms from the currently selected ontologyvoidremoveClass(String classname) Removes class name from the parser vocabulary and currently selected ontologyvoidremoveClasses(String classnames) Removes multiple class names from the parser vocabulary and currently selected ontologyvoidremoveDataProperties(String dpropnames) Removes multiple data properties from the parser vocabulary and currently selected ontologyvoidremoveDataProperty(String dpropname) Removes a data property from the parser vocabulary and currently selected ontologyvoidremoveDProperties(String dpropnames) Alias for removeDataProperties method.voidremoveDProperty(String dpropname) Alias for removeDataProperty method.voidremoveIndividual(String individualname) Removes individual name from the parser vocabulary and currently selected ontologyvoidremoveIndividuals(String indnames) Removes multiple individual names from the parser vocabulary and currently selected ontologyvoidremoveObjectProperties(String opropnames) Removes multiple object properties from the parser vocabulary and currently selected ontologyvoidremoveObjectProperty(String opropname) Removes an object property from the parser vocabulary and currently selected ontologyvoidRemoves selected ontology from the current context (OWLAPILiteFactory instance)voidremoveOntology(String iriStr) Removes an ontology from the current context (OWLAPILiteFactory instance)voidremoveOntology(org.semanticweb.owlapi.model.OWLOntology ontology) Removes an ontology from the current context (OWLAPILiteFactory instance)voidremoveOProperties(String opropnames) Alias for removeObjectProperties method.voidremoveOProperty(String opropname) Alias for removeObjectProperty method.voidRemoves all axioms (logical and otherwise) from the ontologyvoidsaveOntology(String filepath) Saves the currently selected ontology to a local file in Manchester OWL syntaxvoidsetFullIRIRendering(boolean option) Set the type of rendering for OWL entities whenever the client prints a class, property, axiom etc.voidsetNamespace(String iriStr) Changes the namespace of current context.voidsetOntology(String iriStr) Sets the currently selected (active) ontology to be the one denoted by the input IRI stringvoidsetOntology(org.semanticweb.owlapi.model.OWLOntology ontology) Sets the currently selected (active) ontology to be the one denoted by the input OWLOntology referencevoidsetOWLReasoner(SelectedReasoner selectedReasoner) Set or initialise the OWLReasonerFactory implementation to use for this OWLAPILiteFactory instance, based on the reasoner selected
-
Field Details
-
owlReasoner
OWLAPILiteReasoner instance
-
-
Constructor Details
-
OWLAPILiteFactory
public OWLAPILiteFactory()Public constructor for OWLAPILiteFactory
-
-
Method Details
-
getInstance
Static method to get hold of a OWLAPILiteFactory instance- Returns:
- Returns an instance of OWLAPILiteFactory using default reasoner JFACT
-
getInstance
Static method to get hold of a OWLAPILiteFactory instance- Parameters:
selectedReasoner- the reasoner to use with this OWLAPILiteFactory instance- Returns:
- Returns an instance of OWLAPILiteFactory that uses the specified reasoner
-
setOWLReasoner
Set or initialise the OWLReasonerFactory implementation to use for this OWLAPILiteFactory instance, based on the reasoner selected- Parameters:
selectedReasoner- the reasoner to use with this OWLAPILiteFactory instance
-
setFullIRIRendering
public void setFullIRIRendering(boolean option) Set the type of rendering for OWL entities whenever the client prints a class, property, axiom etc. Either the full IRI or the short form label- Parameters:
option- true if the client wishes to print full IRIs for OWL entities, false if the client wants to print only short form labels for OWL entities
-
createOntology
public org.semanticweb.owlapi.model.OWLOntology createOntology(String iriStr) throws org.semanticweb.owlapi.model.OWLOntologyCreationException Creates a new OWL ontology given a string representation of an IRI- Parameters:
iriStr- a string representation of an IRI- Returns:
- an OWLOntology object
- Throws:
org.semanticweb.owlapi.model.OWLOntologyCreationException- if the IRI is invalid
-
setOntology
Sets the currently selected (active) ontology to be the one denoted by the input IRI string- Parameters:
iriStr- a string representation of an IRI for an ontology
-
setOntology
public void setOntology(org.semanticweb.owlapi.model.OWLOntology ontology) Sets the currently selected (active) ontology to be the one denoted by the input OWLOntology reference- Parameters:
ontology- an OWLOntology object
-
getOntology
public org.semanticweb.owlapi.model.OWLOntology getOntology()Prints the IRI string of the currently selected ontology- Returns:
- the currently selected OWLOntology
-
getOntologies
public void getOntologies()Prints the IRI strings of each ontology that has been created so far using this instance of OWLAPILiteFactory -
createClass
Creates a new class name, adds this class to the parser's vocabulary and the currently selected ontology, and prints out the class to the console- Parameters:
classname- A string representation of a class name
-
createObjectProperty
Creates a new object property, adds this object property to the parser's vocabulary and the currently selected ontology, and prints out the object property to the console- Parameters:
opropname- A string representation of an object property
-
createOProperty
Alias for createObjectProperty method. Creates a new object property, adds this object property to the parser's vocabulary and the currently selected ontology, and prints out the object property to the console- Parameters:
opropname- A string representation of an object property
-
createObjectProperty
Creates a new object property, adds this object property to the parser's vocabulary and the currently selected ontology, and prints out the object property to the console- Parameters:
opropname- A string representation of an object propertytrans- an integer value representing whether the object property should be made transitive or not. 1 for transitive and 0 for not making it transitiveref- an integer value representing whether the object property should be made reflexive or not. 1 for reflexive and 0 for not making it reflexive, 2 for making it irreflexivesym- an integer value representing whether the object property should be made symmetric or not. 1 for symmetric and 0 for not making it symmetric, 2 for making it asymmetric
-
createOProperty
Alias for createOProperty method Creates a new object property, adds this object property to the parser's vocabulary and the currently selected ontology, and prints out the object property to the console- Parameters:
opropname- A string representation of an object propertytrans- an integer value representing whether the object property should be made transitive or not. 1 for transitive and 0 for not making it transitiveref- an integer value representing whether the object property should be made reflexive or not. 1 for reflexive and 0 for not making it reflexive, 2 for making it irreflexivesym- an integer value representing whether the object property should be made symmetric or not. 1 for symmetric and 0 for not making it symmetric, 2 for making it asymmetric
-
createDataProperty
Creates a new data property, adds this data property to the parser's vocabulary and the currently selected ontology, and prints out the data property to the console- Parameters:
dpropname- A string representation of a data property
-
createDProperty
Alias for createDataProperty method. Creates a new data property, adds this data property to the parser's vocabulary and the currently selected ontology, and prints out the data property to the console- Parameters:
dpropname- A string representation of a data property
-
createIndividual
Creates a new individual name, adds this individual name to the parser's vocabulary and the currently selected ontology, and prints out the individual name to the console- Parameters:
individualname- A string representation of a individual name
-
createAxiom
Creates a new OWLAxiom, adds this axiom to the currently selected ontology, and prints out the axiom to the console- Parameters:
axiomStr- A string representation of the axiom in Manchester OWL syntax- Returns:
- An OWLAxiom object representing the axiom in the input string
-
setNamespace
Changes the namespace of current context. Future entities created after executing this method will use this namespace- Parameters:
iriStr- A string representation of the desired namespace IRI to change to
-
createClassExpression
public org.semanticweb.owlapi.model.OWLClassExpression createClassExpression(String classExpressionStr) Creates an anonymous class expression and prints out the class expression to the console- Parameters:
classExpressionStr- A string representation of the class expression in Manchester OWL syntax- Returns:
- An OWLClassExpression object representing the class in the input string
-
createClasses
Creates multiple class names, adds them to the parser vocabulary and the currently selected ontology- Parameters:
classnames- A single space separated list of class names
-
createObjectProperties
Creates multiple object properties, adds them to the parser vocabulary and the currently selected ontology- Parameters:
opropsstr- A single space separated list of object properties
-
createOProperties
Alias for createObjectProperties method. Creates multiple object properties, adds them to the parser vocabulary and the currently selected ontology- Parameters:
opropsstr- A single space separated list of object properties
-
createIndividuals
Creates multiple individual names, adds them to the parser vocabulary and the currently selected ontology- Parameters:
indnames- A single space separated list of individual names
-
createDataProperties
Creates multiple data properties, adds them to the parser vocabulary and the currently selected ontology- Parameters:
dpropsstr- A single space separated list of data properties
-
createDProperties
Alias for createDataProperties method. Creates multiple data properties, adds them to the parser vocabulary and the currently selected ontology- Parameters:
dpropsstr- A single space separated list of data properties
-
makeTransitive
Makes an existing object property in the ontology transitive- Parameters:
opropname- A string representation of an object property
-
makeSymmetric
Makes an existing object property in the ontology symmetric- Parameters:
opropname- A string representation of an object property
-
makeReflexive
Makes an existing object property in the ontology reflexive- Parameters:
opropname- A string representation of an object property
-
makeIRReflexive
Makes an existing object property in the ontology irreflexive- Parameters:
opropname- A string representation of an object property
-
makeAntiSymmetric
Makes an existing object property in the ontology asymmetric- Parameters:
opropname- A string representation of an object property
-
createObjectPropertyAssertion
Creates role axiom from string- Parameters:
axiomStr- OWL role assertion axiom string expression- Returns:
- An OWLAxiom object representing the role assertion axiom in the input
-
createOPropertyAssertion
Alias for createObjectPropertyAssertion method- Parameters:
axiomStr- OWL role assertion axiom string expression- Returns:
- An OWLAxiom object representing the role assertion axiom in the input
-
allIndividualsDifferent
public org.semanticweb.owlapi.model.OWLAxiom allIndividualsDifferent()Makes all the individual names in the ontology refer to different individuals (simulate the unique name assumption)- Returns:
- An OWLAxiom which enforces that all individual names in the ontology refer to different individuals (simulating the unique name assumption)
-
differentIndividuals
Makes the specified individual names in the ontology refer to different individuals (simulate the unique name assumption for a subset of individual names)- Parameters:
differentIndividualsStr- a single-space separated list of individual names e.g. "john mary mark" (no quotes).- Returns:
- An OWLAxiom which enforces that the specified individual names refer to different individuals (simulating the unique name assumption for the given individual names)
-
printOntology
public void printOntology()Prints a grouped list of the main logical entities in the ontology to console (classes, properties, individuals, TBox, ABox, RBox etc.) -
print
public void print(org.semanticweb.owlapi.model.OWLAxiom axiom) Prints an OWLAxiom object to console output- Parameters:
axiom- OWLAxiom object to print to console
-
printOntologyStats
public void printOntologyStats()Prints OWLOntology metrics to console output e.g. number of axioms, subclass axioms etc. -
removeClass
Removes class name from the parser vocabulary and currently selected ontology- Parameters:
classname- A string representation of the class name to remove
-
removeClasses
Removes multiple class names from the parser vocabulary and currently selected ontology- Parameters:
classnames- A single space separated list of class names to remove from the ontology e.g. "Student Lecturer Person"
-
removeObjectProperty
Removes an object property from the parser vocabulary and currently selected ontology- Parameters:
opropname- A string representation of the object property to remove
-
removeOProperty
Alias for removeObjectProperty method. Removes an object property from the parser vocabulary and currently selected ontology- Parameters:
opropname- A string representation of the object property to remove
-
removeDataProperty
Removes a data property from the parser vocabulary and currently selected ontology- Parameters:
dpropname- A string representation of the data property to remove
-
removeDProperty
Alias for removeDataProperty method. Removes a data property from the parser vocabulary and currently selected ontology- Parameters:
dpropname- A string representation of the data property to remove
-
removeObjectProperties
Removes multiple object properties from the parser vocabulary and currently selected ontology- Parameters:
opropnames- A single space separated list of object properties to remove from the ontology e.g. "marriedTo hasTopping teachesCourse"
-
removeOProperties
Alias for removeObjectProperties method. Removes multiple object properties from the parser vocabulary and currently selected ontology- Parameters:
opropnames- A single space separated list of object properties to remove from the ontology e.g. "marriedTo hasTopping teachesCourse"
-
removeDataProperties
Removes multiple data properties from the parser vocabulary and currently selected ontology- Parameters:
dpropnames- A single space separated list of data properties to remove from the ontology e.g. "hasHeight hasSalary hasConcentration"
-
removeDProperties
Alias for removeDataProperties method. Removes multiple data properties from the parser vocabulary and currently selected ontology- Parameters:
dpropnames- A single space separated list of data properties to remove from the ontology e.g. "hasHeight hasSalary hasConcentration"
-
removeIndividual
Removes individual name from the parser vocabulary and currently selected ontology- Parameters:
individualname- A string representation of the object property to remove
-
removeIndividuals
Removes multiple individual names from the parser vocabulary and currently selected ontology- Parameters:
indnames- A single space separated list of individual names to remove from the ontology e.g. "john mary mark"
-
removeAxiom
Removes axiom from the currently selected ontology- Parameters:
axiomStr- A string representation of the axiom to remove in Manchester OWL syntax
-
removeAxiom
public void removeAxiom(org.semanticweb.owlapi.model.OWLAxiom a) Removes axiom from the currently selected ontology- Parameters:
a- an OWLAxiom object reference for the axiom to remove
-
removeAxioms
Removes a set of axioms from the currently selected ontology- Parameters:
a- a HashSet of OWLAxiom objects to remove from the ontology
-
resetOntology
public void resetOntology()Removes all axioms (logical and otherwise) from the ontology -
loadFromFile
public org.semanticweb.owlapi.model.OWLOntology loadFromFile(String filepath) throws org.semanticweb.owlapi.model.OWLOntologyCreationException Loads an OWL ontology from local file into the OWLAPILiteFactory instance. This ontology becomes the currently selected ontology.- Parameters:
filepath- a string representation of the relative path to the local ontology file on the local machine- Returns:
- an OWLOntology instance
- Throws:
org.semanticweb.owlapi.model.OWLOntologyCreationException- if the filepath is invalid
-
loadFromURL
public org.semanticweb.owlapi.model.OWLOntology loadFromURL(String url) throws org.semanticweb.owlapi.model.OWLOntologyCreationException Loads an OWL ontology from a remote URL into the OWLAPILiteFactory instance. This ontology becomes the currently selected ontology.- Parameters:
url- a string representation of the URL to the ontology on the Web- Returns:
- an OWLOntology instance
- Throws:
org.semanticweb.owlapi.model.OWLOntologyCreationException- if the remote URL is invalid
-
saveOntology
public void saveOntology(String filepath) throws org.semanticweb.owlapi.model.OWLOntologyStorageException, FileNotFoundException Saves the currently selected ontology to a local file in Manchester OWL syntax- Parameters:
filepath- a string representation of the path and filename to save the ontology to- Throws:
FileNotFoundException- if the filepath is invalidorg.semanticweb.owlapi.model.OWLOntologyStorageException- if there is a serialisation error when saving the ontology to disk
-
removeOntology
Removes an ontology from the current context (OWLAPILiteFactory instance)- Parameters:
iriStr- the IRI string of the ontology to remove
-
removeOntology
public void removeOntology(org.semanticweb.owlapi.model.OWLOntology ontology) Removes an ontology from the current context (OWLAPILiteFactory instance)- Parameters:
ontology- the OWLOntology object to remove
-
removeOntology
public void removeOntology()Removes selected ontology from the current context (OWLAPILiteFactory instance)
-