Class OntologyUtils


  • public class OntologyUtils
    extends java.lang.Object

    Copyright: Copyright (c) 2007

    Company: Clark & Parsia, LLC.

    Author:
    Evren Sirin
    • Constructor Summary

      Constructors 
      Constructor Description
      OntologyUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static void addAxiom​(org.semanticweb.owlapi.model.OWLAxiom axiom, java.util.Set<org.semanticweb.owlapi.model.OWLOntology> ontologies, org.semanticweb.owlapi.model.OWLOntologyManager manager)
      Add the axiom to all the given ontologies.
      static void addAxioms​(org.semanticweb.owlapi.model.OWLOntology ontology, java.util.Collection<? extends org.semanticweb.owlapi.model.OWLAxiom> axioms)
      Deprecated.
      static void addAxioms​(org.semanticweb.owlapi.model.OWLOntology ontology, java.util.stream.Stream<? extends org.semanticweb.owlapi.model.OWLAxiom> axioms)
      Deprecated.
      static void addAxioms​(org.semanticweb.owlapi.model.OWLOntology ontology, org.semanticweb.owlapi.model.OWLAxiom... axioms)
      Deprecated.
      static void clearOWLOntologyManager()
      Deprecated.
      static boolean containsClass​(java.util.Set<java.util.Set<org.semanticweb.owlapi.model.OWLClass>> classes, org.semanticweb.owlapi.model.OWLClass cls)
      Deprecated.
      static boolean containsUnreferencedEntity​(org.semanticweb.owlapi.model.OWLOntology ontology, org.semanticweb.owlapi.model.OWLClassExpression 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.owlapi.model.OWLEntity findEntity​(java.lang.String name, java.util.Set<org.semanticweb.owlapi.model.OWLOntology> ontologies)
      Deprecated.
      static org.semanticweb.owlapi.model.OWLEntity findEntity​(java.lang.String name, java.util.stream.Stream<org.semanticweb.owlapi.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.owlapi.model.OWLEntity findEntity​(java.lang.String name, org.semanticweb.owlapi.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.owlapi.model.OWLOntologyManager getOWLOntologyManager()
      Deprecated.
      static java.util.Set<org.semanticweb.owlapi.model.OWLEntity> getSignature​(org.semanticweb.owlapi.model.OWLAxiom axiom)
      Deprecated.
      2.5.1 use the stream version
      static org.semanticweb.owlapi.model.OWLOntology loadOntology​(java.io.InputStream inputStream)
      Deprecated.
      static org.semanticweb.owlapi.model.OWLOntology loadOntology​(java.io.InputStream inputStream, boolean withAnnotations)
      Deprecated.
      static org.semanticweb.owlapi.model.OWLOntology loadOntology​(java.lang.String uri)
      Deprecated.
      static org.semanticweb.owlapi.model.OWLOntology loadOntology​(java.lang.String uri, boolean withAnnotations)
      Deprecated.
      static org.semanticweb.owlapi.model.OWLOntology loadOntology​(org.semanticweb.owlapi.model.OWLOntologyManager manager, java.io.InputStream inputStream)  
      static org.semanticweb.owlapi.model.OWLOntology loadOntology​(org.semanticweb.owlapi.model.OWLOntologyManager manager, java.io.InputStream inputStream, boolean withAnnotations)  
      static org.semanticweb.owlapi.model.OWLOntology loadOntology​(org.semanticweb.owlapi.model.OWLOntologyManager manager, java.lang.String uri)  
      static org.semanticweb.owlapi.model.OWLOntology loadOntology​(org.semanticweb.owlapi.model.OWLOntologyManager manager, java.lang.String uri, boolean withAnnotations)  
      static void printAxioms​(java.util.Collection<? extends org.semanticweb.owlapi.model.OWLAxiom> axioms)
      Deprecated.
      static void printOntology​(org.semanticweb.owlapi.model.OWLOntology ont)
      Deprecated.
      static void removeAllAnnotations​(org.semanticweb.owlapi.model.OWLOntology ontology)
      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.owlapi.model.OWLOntology> removeAxiom​(org.semanticweb.owlapi.model.OWLAxiom axiom, java.util.Set<org.semanticweb.owlapi.model.OWLOntology> ontologies, org.semanticweb.owlapi.model.OWLOntologyManager manager)
      Removes an axiom from all the given ontologies that contains the axiom and returns those ontologies.
      static void removeAxioms​(org.semanticweb.owlapi.model.OWLOntology ontology, java.util.Collection<? extends org.semanticweb.owlapi.model.OWLAxiom> axioms)  
      static void removeAxioms​(org.semanticweb.owlapi.model.OWLOntology ontology, org.semanticweb.owlapi.model.OWLAxiom... axioms)
      Deprecated.
      static void save​(org.semanticweb.owlapi.model.OWLOntology ont, java.lang.String path)
      Deprecated.
      static java.util.stream.Stream<org.semanticweb.owlapi.model.OWLEntity> signature​(org.semanticweb.owlapi.model.OWLAxiom axiom)
      Deprecated.
      static void updateOntology​(org.semanticweb.owlapi.model.OWLOntology ontology, java.util.Collection<? extends org.semanticweb.owlapi.model.OWLAxiom> axioms, boolean add)  
      static void updateOntology​(org.semanticweb.owlapi.model.OWLOntology ontology, java.util.stream.Stream<? extends org.semanticweb.owlapi.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

        @Deprecated
        public static void addAxioms​(org.semanticweb.owlapi.model.OWLOntology ontology,
                                     java.util.Collection<? extends org.semanticweb.owlapi.model.OWLAxiom> axioms)
        Deprecated.
      • addAxioms

        @Deprecated
        public static void addAxioms​(org.semanticweb.owlapi.model.OWLOntology ontology,
                                     java.util.stream.Stream<? extends org.semanticweb.owlapi.model.OWLAxiom> axioms)
        Deprecated.
      • addAxioms

        @Deprecated
        public static void addAxioms​(org.semanticweb.owlapi.model.OWLOntology ontology,
                                     org.semanticweb.owlapi.model.OWLAxiom... axioms)
        Deprecated.
      • containsClass

        @Deprecated
        public static boolean containsClass​(java.util.Set<java.util.Set<org.semanticweb.owlapi.model.OWLClass>> classes,
                                            org.semanticweb.owlapi.model.OWLClass cls)
        Deprecated.
      • getSignature

        @Deprecated
        public static java.util.Set<org.semanticweb.owlapi.model.OWLEntity> getSignature​(org.semanticweb.owlapi.model.OWLAxiom axiom)
        Deprecated.
        2.5.1 use the stream version
        Given an axiom, return its signature.
      • signature

        @Deprecated
        public static java.util.stream.Stream<org.semanticweb.owlapi.model.OWLEntity> signature​(org.semanticweb.owlapi.model.OWLAxiom axiom)
        Deprecated.
      • getOWLOntologyManager

        @Deprecated
        public static org.semanticweb.owlapi.model.OWLOntologyManager getOWLOntologyManager()
        Deprecated.
      • clearOWLOntologyManager

        @Deprecated
        public static void clearOWLOntologyManager()
        Deprecated.
      • loadOntology

        @Deprecated
        public static org.semanticweb.owlapi.model.OWLOntology loadOntology​(java.lang.String uri)
        Deprecated.
        Loads the ontology with given URI.
        Parameters:
        uri - the ontology uri
        Returns:
        the ontology
      • loadOntology

        public static org.semanticweb.owlapi.model.OWLOntology loadOntology​(org.semanticweb.owlapi.model.OWLOntologyManager manager,
                                                                            java.lang.String uri)
      • loadOntology

        @Deprecated
        public static org.semanticweb.owlapi.model.OWLOntology loadOntology​(java.io.InputStream inputStream)
        Deprecated.
        Loads the ontology with given URI.
        Parameters:
        inputStream - input ontology
        Returns:
        the ontology
      • loadOntology

        public static org.semanticweb.owlapi.model.OWLOntology loadOntology​(org.semanticweb.owlapi.model.OWLOntologyManager manager,
                                                                            java.io.InputStream inputStream)
      • loadOntology

        @Deprecated
        public static org.semanticweb.owlapi.model.OWLOntology loadOntology​(java.lang.String uri,
                                                                            boolean withAnnotations)
        Deprecated.
        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)
      • loadOntology

        public static org.semanticweb.owlapi.model.OWLOntology loadOntology​(org.semanticweb.owlapi.model.OWLOntologyManager manager,
                                                                            java.lang.String uri,
                                                                            boolean withAnnotations)
      • loadOntology

        @Deprecated
        public static org.semanticweb.owlapi.model.OWLOntology loadOntology​(java.io.InputStream inputStream,
                                                                            boolean withAnnotations)
        Deprecated.
        Loads the ontology with given URI and optionally removes all annotations leaving only logical axioms.
        Parameters:
        inputStream - input stream
        withAnnotations - if false removes all annotation axioms from the ontology, otherwise leaves the ontology intact
        Returns:
        the ontology
        See Also:
        #removeAllAnnotations(OWLOntology, OWLOntologyManager)
      • loadOntology

        public static org.semanticweb.owlapi.model.OWLOntology loadOntology​(org.semanticweb.owlapi.model.OWLOntologyManager manager,
                                                                            java.io.InputStream inputStream,
                                                                            boolean withAnnotations)
      • printAxioms

        @Deprecated
        public static void printAxioms​(java.util.Collection<? extends org.semanticweb.owlapi.model.OWLAxiom> axioms)
        Deprecated.
        Prints a set of axioms to console
      • printOntology

        @Deprecated
        public static void printOntology​(org.semanticweb.owlapi.model.OWLOntology ont)
        Deprecated.
        Prints an ontology to console
      • removeAxioms

        public static void removeAxioms​(org.semanticweb.owlapi.model.OWLOntology ontology,
                                        java.util.Collection<? extends org.semanticweb.owlapi.model.OWLAxiom> axioms)
      • removeAxioms

        @Deprecated
        public static void removeAxioms​(org.semanticweb.owlapi.model.OWLOntology ontology,
                                        org.semanticweb.owlapi.model.OWLAxiom... axioms)
        Deprecated.
      • save

        @Deprecated
        public static void save​(org.semanticweb.owlapi.model.OWLOntology ont,
                                java.lang.String path)
                         throws org.semanticweb.owlapi.model.OWLOntologyStorageException
        Deprecated.
        Throws:
        org.semanticweb.owlapi.model.OWLOntologyStorageException
      • updateOntology

        public static void updateOntology​(org.semanticweb.owlapi.model.OWLOntology ontology,
                                          java.util.stream.Stream<? extends org.semanticweb.owlapi.model.OWLAxiom> axioms,
                                          boolean add)
        Update the ontology by adding or removing the given set of axioms
        Parameters:
        ontology - target ontology
        axioms - the axiom to add/remove
        add - true - add; false - delete
      • updateOntology

        public static void updateOntology​(org.semanticweb.owlapi.model.OWLOntology ontology,
                                          java.util.Collection<? extends org.semanticweb.owlapi.model.OWLAxiom> axioms,
                                          boolean add)
      • containsUnreferencedEntity

        public static boolean containsUnreferencedEntity​(org.semanticweb.owlapi.model.OWLOntology ontology,
                                                         org.semanticweb.owlapi.model.OWLClassExpression 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.owlapi.model.OWLOntology> removeAxiom​(org.semanticweb.owlapi.model.OWLAxiom axiom,
                                                                                          java.util.Set<org.semanticweb.owlapi.model.OWLOntology> ontologies,
                                                                                          org.semanticweb.owlapi.model.OWLOntologyManager manager)
        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
      • addAxiom

        public static void addAxiom​(org.semanticweb.owlapi.model.OWLAxiom axiom,
                                    java.util.Set<org.semanticweb.owlapi.model.OWLOntology> ontologies,
                                    org.semanticweb.owlapi.model.OWLOntologyManager manager)
        Add the axiom to all the given ontologies.
        Parameters:
        axiom -
        ontologies -
        _manager -
      • removeAllAnnotations

        public static void removeAllAnnotations​(org.semanticweb.owlapi.model.OWLOntology ontology)
        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
      • findEntity

        public static org.semanticweb.owlapi.model.OWLEntity findEntity​(java.lang.String name,
                                                                        java.util.stream.Stream<org.semanticweb.owlapi.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

        @Deprecated
        public static org.semanticweb.owlapi.model.OWLEntity findEntity​(java.lang.String name,
                                                                        java.util.Set<org.semanticweb.owlapi.model.OWLOntology> ontologies)
        Deprecated.
      • findEntity

        public static org.semanticweb.owlapi.model.OWLEntity findEntity​(java.lang.String name,
                                                                        org.semanticweb.owlapi.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