Class OWLAPILiteFactory

java.lang.Object
io.github.kodymoodley.owlapilite.OWLAPILiteFactory

public class OWLAPILiteFactory extends Object
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
    Modifier and Type
    Field
    Description
    OWLAPILiteReasoner instance
  • Constructor Summary

    Constructors
    Constructor
    Description
    Public constructor for OWLAPILiteFactory
  • Method Summary

    Modifier and Type
    Method
    Description
    org.semanticweb.owlapi.model.OWLAxiom
    Makes all the individual names in the ontology refer to different individuals (simulate the unique name assumption)
    org.semanticweb.owlapi.model.OWLAxiom
    createAxiom(String axiomStr)
    Creates a new OWLAxiom, adds this axiom to the currently selected ontology, and prints out the axiom to the console
    void
    createClass(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 console
    void
    createClasses(String classnames)
    Creates multiple class names, adds them to the parser vocabulary and the currently selected ontology
    org.semanticweb.owlapi.model.OWLClassExpression
    createClassExpression(String classExpressionStr)
    Creates an anonymous class expression and prints out the class expression to the console
    void
    Creates multiple data properties, adds them to the parser vocabulary and the currently selected ontology
    void
    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
    void
    Alias for createDataProperties method.
    void
    Alias for createDataProperty method.
    void
    createIndividual(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 console
    void
    Creates multiple individual names, adds them to the parser vocabulary and the currently selected ontology
    void
    Creates multiple object properties, adds them to the parser vocabulary and the currently selected ontology
    void
    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
    void
    createObjectProperty(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 console
    org.semanticweb.owlapi.model.OWLAxiom
    Creates role axiom from string
    org.semanticweb.owlapi.model.OWLOntology
    Creates a new OWL ontology given a string representation of an IRI
    void
    Alias for createObjectProperties method.
    void
    Alias for createObjectProperty method.
    void
    createOProperty(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 console
    org.semanticweb.owlapi.model.OWLAxiom
    Alias for createObjectPropertyAssertion method
    org.semanticweb.owlapi.model.OWLAxiom
    differentIndividuals(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 method to get hold of a OWLAPILiteFactory instance
    getInstance(SelectedReasoner selectedReasoner)
    Static method to get hold of a OWLAPILiteFactory instance
    void
    Prints the IRI strings of each ontology that has been created so far using this instance of OWLAPILiteFactory
    org.semanticweb.owlapi.model.OWLOntology
    Prints the IRI string of the currently selected ontology
    org.semanticweb.owlapi.model.OWLOntology
    loadFromFile(String filepath)
    Loads an OWL ontology from local file into the OWLAPILiteFactory instance.
    org.semanticweb.owlapi.model.OWLOntology
    Loads an OWL ontology from a remote URL into the OWLAPILiteFactory instance.
    void
    Makes an existing object property in the ontology asymmetric
    void
    Makes an existing object property in the ontology irreflexive
    void
    makeReflexive(String opropname)
    Makes an existing object property in the ontology reflexive
    void
    makeSymmetric(String opropname)
    Makes an existing object property in the ontology symmetric
    void
    Makes an existing object property in the ontology transitive
    void
    print(org.semanticweb.owlapi.model.OWLAxiom axiom)
    Prints an OWLAxiom object to console output
    void
    Prints a grouped list of the main logical entities in the ontology to console (classes, properties, individuals, TBox, ABox, RBox etc.)
    void
    Prints OWLOntology metrics to console output e.g.
    void
    removeAxiom(String axiomStr)
    Removes axiom from the currently selected ontology
    void
    removeAxiom(org.semanticweb.owlapi.model.OWLAxiom a)
    Removes axiom from the currently selected ontology
    void
    removeAxioms(Set<org.semanticweb.owlapi.model.OWLAxiom> a)
    Removes a set of axioms from the currently selected ontology
    void
    removeClass(String classname)
    Removes class name from the parser vocabulary and currently selected ontology
    void
    removeClasses(String classnames)
    Removes multiple class names from the parser vocabulary and currently selected ontology
    void
    Removes multiple data properties from the parser vocabulary and currently selected ontology
    void
    Removes a data property from the parser vocabulary and currently selected ontology
    void
    Alias for removeDataProperties method.
    void
    Alias for removeDataProperty method.
    void
    removeIndividual(String individualname)
    Removes individual name from the parser vocabulary and currently selected ontology
    void
    Removes multiple individual names from the parser vocabulary and currently selected ontology
    void
    Removes multiple object properties from the parser vocabulary and currently selected ontology
    void
    Removes an object property from the parser vocabulary and currently selected ontology
    void
    Removes selected ontology from the current context (OWLAPILiteFactory instance)
    void
    Removes an ontology from the current context (OWLAPILiteFactory instance)
    void
    removeOntology(org.semanticweb.owlapi.model.OWLOntology ontology)
    Removes an ontology from the current context (OWLAPILiteFactory instance)
    void
    Alias for removeObjectProperties method.
    void
    Alias for removeObjectProperty method.
    void
    Removes all axioms (logical and otherwise) from the ontology
    void
    saveOntology(String filepath)
    Saves the currently selected ontology to a local file in Manchester OWL syntax
    void
    setFullIRIRendering(boolean option)
    Set the type of rendering for OWL entities whenever the client prints a class, property, axiom etc.
    void
    Changes the namespace of current context.
    void
    Sets the currently selected (active) ontology to be the one denoted by the input IRI string
    void
    setOntology(org.semanticweb.owlapi.model.OWLOntology ontology)
    Sets the currently selected (active) ontology to be the one denoted by the input OWLOntology reference
    void
    setOWLReasoner(SelectedReasoner selectedReasoner)
    Set or initialise the OWLReasonerFactory implementation to use for this OWLAPILiteFactory instance, based on the reasoner selected

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • OWLAPILiteFactory

      public OWLAPILiteFactory()
      Public constructor for OWLAPILiteFactory
  • Method Details

    • getInstance

      public static OWLAPILiteFactory getInstance()
      Static method to get hold of a OWLAPILiteFactory instance
      Returns:
      Returns an instance of OWLAPILiteFactory using default reasoner JFACT
    • getInstance

      public static OWLAPILiteFactory getInstance(SelectedReasoner selectedReasoner)
      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

      public void setOWLReasoner(SelectedReasoner selectedReasoner)
      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

      public void setOntology(String iriStr)
      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

      public void createClass(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 console
      Parameters:
      classname - A string representation of a class name
    • createObjectProperty

      public void createObjectProperty(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 console
      Parameters:
      opropname - A string representation of an object property
    • createOProperty

      public void createOProperty(String opropname)
      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

      public void createObjectProperty(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 console
      Parameters:
      opropname - A string representation of an object property
      trans - an integer value representing whether the object property should be made transitive or not. 1 for transitive and 0 for not making it transitive
      ref - 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 irreflexive
      sym - 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

      public void createOProperty(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 console
      Parameters:
      opropname - A string representation of an object property
      trans - an integer value representing whether the object property should be made transitive or not. 1 for transitive and 0 for not making it transitive
      ref - 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 irreflexive
      sym - 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

      public void createDataProperty(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 console
      Parameters:
      dpropname - A string representation of a data property
    • createDProperty

      public void createDProperty(String dpropname)
      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

      public void createIndividual(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 console
      Parameters:
      individualname - A string representation of a individual name
    • createAxiom

      public org.semanticweb.owlapi.model.OWLAxiom createAxiom(String axiomStr)
      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

      public void setNamespace(String iriStr)
      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

      public void createClasses(String classnames)
      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

      public void createObjectProperties(String opropsstr)
      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

      public void createOProperties(String opropsstr)
      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

      public void createIndividuals(String indnames)
      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

      public void createDataProperties(String dpropsstr)
      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

      public void createDProperties(String dpropsstr)
      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

      public void makeTransitive(String opropname)
      Makes an existing object property in the ontology transitive
      Parameters:
      opropname - A string representation of an object property
    • makeSymmetric

      public void makeSymmetric(String opropname)
      Makes an existing object property in the ontology symmetric
      Parameters:
      opropname - A string representation of an object property
    • makeReflexive

      public void makeReflexive(String opropname)
      Makes an existing object property in the ontology reflexive
      Parameters:
      opropname - A string representation of an object property
    • makeIRReflexive

      public void makeIRReflexive(String opropname)
      Makes an existing object property in the ontology irreflexive
      Parameters:
      opropname - A string representation of an object property
    • makeAntiSymmetric

      public void makeAntiSymmetric(String opropname)
      Makes an existing object property in the ontology asymmetric
      Parameters:
      opropname - A string representation of an object property
    • createObjectPropertyAssertion

      public org.semanticweb.owlapi.model.OWLAxiom createObjectPropertyAssertion(String axiomStr)
      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

      public org.semanticweb.owlapi.model.OWLAxiom createOPropertyAssertion(String axiomStr)
      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

      public org.semanticweb.owlapi.model.OWLAxiom differentIndividuals(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)
      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

      public void removeClass(String classname)
      Removes class name from the parser vocabulary and currently selected ontology
      Parameters:
      classname - A string representation of the class name to remove
    • removeClasses

      public void removeClasses(String classnames)
      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

      public void removeObjectProperty(String opropname)
      Removes an object property from the parser vocabulary and currently selected ontology
      Parameters:
      opropname - A string representation of the object property to remove
    • removeOProperty

      public void removeOProperty(String opropname)
      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

      public void removeDataProperty(String dpropname)
      Removes a data property from the parser vocabulary and currently selected ontology
      Parameters:
      dpropname - A string representation of the data property to remove
    • removeDProperty

      public void removeDProperty(String dpropname)
      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

      public void removeObjectProperties(String opropnames)
      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

      public void removeOProperties(String opropnames)
      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

      public void removeDataProperties(String dpropnames)
      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

      public void removeDProperties(String dpropnames)
      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

      public void removeIndividual(String individualname)
      Removes individual name from the parser vocabulary and currently selected ontology
      Parameters:
      individualname - A string representation of the object property to remove
    • removeIndividuals

      public void removeIndividuals(String indnames)
      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

      public void removeAxiom(String axiomStr)
      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

      public void removeAxioms(Set<org.semanticweb.owlapi.model.OWLAxiom> a)
      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 invalid
      org.semanticweb.owlapi.model.OWLOntologyStorageException - if there is a serialisation error when saving the ontology to disk
    • removeOntology

      public void removeOntology(String iriStr)
      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)