com.clarkparsia.owlapi
Class OntologyUtils

java.lang.Object
  extended by com.clarkparsia.owlapi.OntologyUtils

public class OntologyUtils
extends java.lang.Object

Title:

Description:

Copyright: Copyright (c) 2007

Company: Clark & Parsia, LLC.

Author:
Evren Sirin

Constructor Summary
OntologyUtils()
           
 
Method Summary
static void addAxiom(org.semanticweb.owl.model.OWLAxiom axiom, java.util.Set<org.semanticweb.owl.model.OWLOntology> ontologies, org.semanticweb.owl.model.OWLOntologyManager manager)
          Add the axiom to all the given ontologies.
static void addAxioms(org.semanticweb.owl.model.OWLOntology ontology, java.util.Collection<? extends org.semanticweb.owl.model.OWLAxiom> axioms)
           
static boolean containsClass(java.util.Set<java.util.Set<org.semanticweb.owl.model.OWLClass>> classes, org.semanticweb.owl.model.OWLClass cls)
           
static boolean containsUnreferencedEntity(org.semanticweb.owl.model.OWLOntology ontology, org.semanticweb.owl.model.OWLDescription desc)
          Determines if a class description contains any unreferenced entities with respect to the ontology that contains the entailments which are being explained.
static org.semanticweb.owl.model.OWLEntity findEntity(java.lang.String name, org.semanticweb.owl.model.OWLOntology ontology)
          Finds an entity (class, individual, object or data property) in the given ontology that has the given local name or URI.
static org.semanticweb.owl.model.OWLEntity findEntity(java.lang.String name, java.util.Set<org.semanticweb.owl.model.OWLOntology> ontologies)
          Finds an entity (class, individual, object or data property) in the given set of ontologies that has the given local name or URI.
static org.semanticweb.owl.model.OWLOntology getOntologyFromAxioms(java.util.Collection<org.semanticweb.owl.model.OWLAxiom> axioms)
           
static org.semanticweb.owl.model.OWLOntology getOntologyFromAxioms(java.util.Collection<org.semanticweb.owl.model.OWLAxiom> axioms, java.net.URI uri)
           
static org.semanticweb.owl.model.OWLOntologyManager getOWLOntologyManager()
           
static java.util.Set<org.semanticweb.owl.model.OWLEntity> getSignature(org.semanticweb.owl.model.OWLAxiom axiom)
          Given a set of OWL-API axiom, return its signature.
static org.semanticweb.owl.model.OWLOntology loadOntology(java.lang.String uri)
          Loads the ontology with given URI.
static org.semanticweb.owl.model.OWLOntology loadOntology(java.lang.String uri, boolean withAnnotations)
          Loads the ontology with given URI and optionally removes all annotations leaving only logical axioms.
static void printAxioms(java.util.Collection<org.semanticweb.owl.model.OWLAxiom> axioms)
          Prints a set of axioms to console
static void printOntology(org.semanticweb.owl.model.OWLOntology ont)
          Prints an ontology to console
static void removeAllAnnotations(org.semanticweb.owl.model.OWLOntology ontology, org.semanticweb.owl.model.OWLOntologyManager manager)
          Removes all annotations (non-logical axioms) from the ontology causing the ontology to be changed in an unreversible way.
static java.util.Set<org.semanticweb.owl.model.OWLOntology> removeAxiom(org.semanticweb.owl.model.OWLAxiom axiom, java.util.Set<org.semanticweb.owl.model.OWLOntology> ontologies, org.semanticweb.owl.model.OWLOntologyManager manager)
          Removes an axiom from all the given ontologies that contains the axiom and returns those ontologies.
static void removeAxioms(org.semanticweb.owl.model.OWLOntology ontology, java.util.Collection<? extends org.semanticweb.owl.model.OWLAxiom> axioms)
           
static void save(org.semanticweb.owl.model.OWLOntology ont, java.lang.String path)
           
static void updateOntology(org.semanticweb.owl.model.OWLOntology ontology, java.util.Collection<? extends org.semanticweb.owl.model.OWLAxiom> axioms, boolean add)
          Update the ontology by adding or removing the given set of axioms
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OntologyUtils

public OntologyUtils()
Method Detail

addAxioms

public static void addAxioms(org.semanticweb.owl.model.OWLOntology ontology,
                             java.util.Collection<? extends org.semanticweb.owl.model.OWLAxiom> axioms)
                      throws org.semanticweb.owl.model.OWLException
Throws:
org.semanticweb.owl.model.OWLException

containsClass

public static boolean containsClass(java.util.Set<java.util.Set<org.semanticweb.owl.model.OWLClass>> classes,
                                    org.semanticweb.owl.model.OWLClass cls)

getSignature

public static java.util.Set<org.semanticweb.owl.model.OWLEntity> getSignature(org.semanticweb.owl.model.OWLAxiom axiom)
Given a set of OWL-API axiom, return its signature.


getOntologyFromAxioms

public static org.semanticweb.owl.model.OWLOntology getOntologyFromAxioms(java.util.Collection<org.semanticweb.owl.model.OWLAxiom> axioms)

getOntologyFromAxioms

public static org.semanticweb.owl.model.OWLOntology getOntologyFromAxioms(java.util.Collection<org.semanticweb.owl.model.OWLAxiom> axioms,
                                                                          java.net.URI uri)

getOWLOntologyManager

public static org.semanticweb.owl.model.OWLOntologyManager getOWLOntologyManager()

loadOntology

public static org.semanticweb.owl.model.OWLOntology loadOntology(java.lang.String uri)
Loads the ontology with given URI.

Parameters:
uri - the ontology uri
Returns:
the ontology

loadOntology

public static org.semanticweb.owl.model.OWLOntology loadOntology(java.lang.String uri,
                                                                 boolean withAnnotations)
Loads the ontology with given URI and optionally removes all annotations leaving only logical axioms.

Parameters:
uri - the ontology uri
withAnnotations - if false removes all annotation axioms from the ontology, otherwise leaves the ontology intact
Returns:
the ontology
See Also:
removeAllAnnotations(OWLOntology, OWLOntologyManager)

printAxioms

public static void printAxioms(java.util.Collection<org.semanticweb.owl.model.OWLAxiom> axioms)
Prints a set of axioms to console

Parameters:
args -

printOntology

public static void printOntology(org.semanticweb.owl.model.OWLOntology ont)
Prints an ontology to console

Parameters:
args -

removeAxioms

public static void removeAxioms(org.semanticweb.owl.model.OWLOntology ontology,
                                java.util.Collection<? extends org.semanticweb.owl.model.OWLAxiom> axioms)
                         throws org.semanticweb.owl.model.OWLException
Throws:
org.semanticweb.owl.model.OWLException

save

public static void save(org.semanticweb.owl.model.OWLOntology ont,
                        java.lang.String path)
                 throws org.semanticweb.owl.model.UnknownOWLOntologyException,
                        org.semanticweb.owl.model.OWLOntologyStorageException
Throws:
org.semanticweb.owl.model.UnknownOWLOntologyException
org.semanticweb.owl.model.OWLOntologyStorageException

updateOntology

public static void updateOntology(org.semanticweb.owl.model.OWLOntology ontology,
                                  java.util.Collection<? extends org.semanticweb.owl.model.OWLAxiom> axioms,
                                  boolean add)
                           throws org.semanticweb.owl.model.OWLException
Update the ontology by adding or removing the given set of axioms

Parameters:
OWLObject - axiom - the axiom to add/remove
boolean - add - true - add; false - delete
Throws:
org.semanticweb.owl.model.OWLException

containsUnreferencedEntity

public static boolean containsUnreferencedEntity(org.semanticweb.owl.model.OWLOntology ontology,
                                                 org.semanticweb.owl.model.OWLDescription desc)
Determines if a class description contains any unreferenced entities with respect to the ontology that contains the entailments which are being explained.

Parameters:
desc - The description to be searched
Returns:
true if the description references entities that the ontology that contains entailments which are being explained, otherwise false

removeAxiom

public static java.util.Set<org.semanticweb.owl.model.OWLOntology> removeAxiom(org.semanticweb.owl.model.OWLAxiom axiom,
                                                                               java.util.Set<org.semanticweb.owl.model.OWLOntology> ontologies,
                                                                               org.semanticweb.owl.model.OWLOntologyManager manager)
                                                                        throws org.semanticweb.owl.model.OWLOntologyChangeException
Removes an axiom from all the given ontologies that contains the axiom and returns those ontologies.

Parameters:
axiom - axiom being removed
ontologies - ontologies from which axiom is being removed
manager - manager to apply the actual change
Returns:
set of ontologies that have been affected
Throws:
org.semanticweb.owl.model.OWLOntologyChangeException

addAxiom

public static void addAxiom(org.semanticweb.owl.model.OWLAxiom axiom,
                            java.util.Set<org.semanticweb.owl.model.OWLOntology> ontologies,
                            org.semanticweb.owl.model.OWLOntologyManager manager)
                     throws org.semanticweb.owl.model.OWLOntologyChangeException
Add the axiom to all the given ontologies.

Parameters:
axiom -
ontologies -
manager -
Throws:
org.semanticweb.owl.model.OWLOntologyChangeException

removeAllAnnotations

public static void removeAllAnnotations(org.semanticweb.owl.model.OWLOntology ontology,
                                        org.semanticweb.owl.model.OWLOntologyManager manager)
Removes all annotations (non-logical axioms) from the ontology causing the ontology to be changed in an unreversible way. For any entity that is only referenced in an annotation but no logical axiom a declaration is added so that the referenced entities by the ontology remain same. Annotations have no semantic importance and can be ignored for reasoning purposes including generating explanations and computing modules. Removing them from the ontology completely reduces the memory requirements which is very high for large-scale annotation-heavy ontologies.

Parameters:
ontology - the ontology being changed
Throws:
org.semanticweb.owl.model.OWLOntologyChangeException

findEntity

public static org.semanticweb.owl.model.OWLEntity findEntity(java.lang.String name,
                                                             java.util.Set<org.semanticweb.owl.model.OWLOntology> ontologies)
Finds an entity (class, individual, object or data property) in the given set of ontologies that has the given local name or URI.

Parameters:
name - URI or local name for an entity
ontologies - ontologies we are searching
Returns:
an entity referenced in the given ontology that has the given URI or local name
See Also:
findEntity(String, OWLOntology)

findEntity

public static org.semanticweb.owl.model.OWLEntity findEntity(java.lang.String name,
                                                             org.semanticweb.owl.model.OWLOntology ontology)
Finds an entity (class, individual, object or data property) in the given ontology that has the given local name or URI. If the given name is not an absolute URI we use the logical URI of the ontology as the namespace and search for an entity with that URI. If the URI is punned in the ontology , e.g. used both as a class and as an individual, any one of the punned entities may be returned.

Parameters:
name - URI or local name for an entity
ontology - ontology we are searching
Returns:
an entity referenced in the given ontology that has the given URI or local name


Copyright © 2004 Evren Sirin. All Rights Reserved.