Package helper

Class OWLMaster

java.lang.Object
helper.OWLMaster

public class OWLMaster extends Object
Contains helper methods for interacting with OWL knowledge bases.
Author:
Afonso Caniço, Afonso Sampaio, Gustavo Ferreira, Samuel Correia
  • Constructor Details

    • OWLMaster

      public OWLMaster()
  • Method Details

    • purgeOntologyMap

      public static void purgeOntologyMap(String kbPath)
      Deletes a mapping from the stored ontology map.
      Parameters:
      kbPath - The knowledge base location of the ontology to be removed.
    • getOntologyFromFile

      public static org.semanticweb.owlapi.model.OWLOntology getOntologyFromFile(String kbPath)
      Loads an OWL knowledge base from the file at the given path.
      Parameters:
      kbPath - The path to the OWL knowledge base file.
      Returns:
      The ontology present in the specified knowledge base.
    • getOntologyFromFile

      public static org.semanticweb.owlapi.model.OWLOntology getOntologyFromFile(File kbFile)
      Loads an OWL knowledge base from the given file.
      Parameters:
      kbFile - An OWL knowledge base file.
      Returns:
      The ontology present in the specified knowledge base.
    • getOntologySignature

      public static SortedSet<org.semanticweb.owlapi.model.OWLEntity> getOntologySignature(org.semanticweb.owlapi.model.OWLOntology ontology)
      Gets the signature of an ontology, i.e. the set of all entities in that ontology.
      Parameters:
      ontology - The OWL ontology you want to get the signature from.
      Returns:
      The signature (set of entities) of the given ontology.
    • getOntologySignature

      public static SortedSet<org.semanticweb.owlapi.model.OWLEntity> getOntologySignature(String kbPath)
      Loads an ontology from a given OWL knowledge base file and returns its signature.
      Parameters:
      kbPath - The path to the OWL knowledge base file.
      Returns:
      The signature (set of entities) of the loaded ontology.
    • getOntologyClassNames

      public static SortedSet<String> getOntologyClassNames(String kbPath)
      Gets the set of the names of all OWL Classes in the ontology in alphabetical order.
      Parameters:
      kbPath - The path to the ontology's knowledge base.
      Returns:
      A set of strings corresponding to the names of every OWLClass in the given ontology's signature.
    • getOntologyObjectPropertyNames

      public static SortedSet<String> getOntologyObjectPropertyNames(String kbPath)
      Gets the set of the names of all OWL Object Properties in the ontology in alphabetical order.
      Parameters:
      kbPath - The path to the ontology's knowledge base.
      Returns:
      A set of strings corresponding to the names of every OWL Object Property in the given ontology's signature.
    • getOntologyDataPropertyNames

      public static SortedSet<String> getOntologyDataPropertyNames(String kbPath)
      Gets the set of the names of all OWL Data Properties in the ontology in alphabetical order.
      Parameters:
      kbPath - The path to the ontology's knowledge base.
      Returns:
      A set of strings corresponding to the names of every OWL Data Property in the given ontology's signature.
    • getAllRelationNames

      public static SortedSet<String> getAllRelationNames(String kbPath)
      Gets the set of the names of all OWL relations (object and data properties, built-ins, etc.) in the ontology in alphabetical order.
      Parameters:
      kbPath - The path to the ontology's knowledge base.
      Returns:
      A set of strings corresponding to the names of every relation (object/data property, built-in, etc.) in the given ontology.
    • getOntologyIndividualNames

      public static SortedSet<String> getOntologyIndividualNames(String kbPath)
      Gets the set of the names of all OWL Inidividuals in the ontology in alphabetical order.
      Parameters:
      kbPath - The path to the ontology's knowledge base.
      Returns:
      A set of strings corresponding to the names of every OWL Individual in the given ontology's signature.
    • getPrefixedBuiltInNames

      public static SortedSet<String> getPrefixedBuiltInNames(String prefix)
      Gets every SWRLAPI built-in with the specified prefix.
      Parameters:
      prefix - The built-in prefix. E.g: 'swrlb', 'sqwrl', etc.
      Returns:
      The set of all (prefixed) names of the built-ins associated with the given prefix.
    • query

      public static org.swrlapi.sqwrl.SQWRLResult query(org.semanticweb.owlapi.model.OWLOntology ontology, String query)
      Queries an ontology using the given SQWRL query string.
      Parameters:
      ontology - The ontology to query.
      query - The SQWRL query to execute.
      Returns:
      The result (SQWRLResult instance) of the query execution.
    • query

      public static org.swrlapi.sqwrl.SQWRLResult query(String kbPath, String query)
      Queries an ontology from a given knowledge base file using the given SQWRL query string.
      Parameters:
      kbPath - The path to the desired ontology's knowledge base file.
      query - The SQWRL query to execute.
      Returns:
      The result (SQWRLResult instance) of the query execution.
    • isValidOntologyFile

      public static boolean isValidOntologyFile(File file)
      Is the specified file a valid OWL document?
      Parameters:
      file - The file to check.
      Returns:
      True if the file is a valid, well-formed OWL file; False, otherwise.
    • getEncodedOntologyID

      public static String getEncodedOntologyID(org.semanticweb.owlapi.model.OWLOntology ontology)
      Gets the encoded ID of an OWL ontology.
      Parameters:
      ontology - An OWL ontology instance.
      Returns:
      A filename-ready version of the given ontology's ID.