Search in sources :

Example 6 with OWLClassExpression

use of org.semanticweb.owlapi.model.OWLClassExpression in project stanbol by apache.

the class RegistryUtils method getType.

@Deprecated
public static Type getType(final OWLIndividual ind, Set<OWLOntology> ontologies) {
    // 0 is for library, 1 is for ontology (more in the future?)
    final int[] pointsFor = new int[] { 0, 0 };
    final int[] pointsAgainst = new int[] { 0, 0 };
    OWLAxiomVisitor v = new OWLAxiomVisitorAdapter() {

        @Override
        public void visit(OWLClassAssertionAxiom axiom) {
            if (ind.equals(axiom.getIndividual())) {
                OWLClassExpression type = axiom.getClassExpression();
                if (cRegistryLibrary.equals(type)) {
                    pointsFor[0]++;
                    pointsAgainst[1]++;
                } else if (cOntology.equals(type)) {
                    pointsFor[1]++;
                    pointsAgainst[0]++;
                }
            }
        }

        @Override
        public void visit(OWLObjectPropertyAssertionAxiom axiom) {
            OWLObjectPropertyExpression prop = axiom.getProperty();
            if (ind.equals(axiom.getSubject())) {
                if (hasOntology.equals(prop)) {
                    pointsFor[0]++;
                    pointsAgainst[1]++;
                } else if (isOntologyOf.equals(prop)) {
                    pointsFor[1]++;
                    pointsAgainst[0]++;
                }
            } else if (ind.equals(axiom.getObject())) {
                if (isOntologyOf.equals(prop)) {
                    pointsFor[0]++;
                    pointsAgainst[1]++;
                } else if (hasOntology.equals(prop)) {
                    pointsFor[1]++;
                    pointsAgainst[0]++;
                }
            }
        }
    };
    // TODO use this strategy in the single pass algorithm for constructing the model.
    for (OWLOntology o : ontologies) for (OWLAxiom ax : o.getAxioms()) ax.accept(v);
    if (pointsFor[0] > 0 && pointsAgainst[0] == 0)
        return Type.LIBRARY;
    if (pointsFor[1] > 0 && pointsAgainst[1] == 0)
        return Type.ONTOLOGY;
    // Cannot determine registries, since they have no associated individual.
    return null;
}
Also used : OWLAxiomVisitor(org.semanticweb.owlapi.model.OWLAxiomVisitor) OWLObjectPropertyExpression(org.semanticweb.owlapi.model.OWLObjectPropertyExpression) OWLOntology(org.semanticweb.owlapi.model.OWLOntology) OWLObjectPropertyAssertionAxiom(org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom) OWLClassExpression(org.semanticweb.owlapi.model.OWLClassExpression) OWLAxiom(org.semanticweb.owlapi.model.OWLAxiom) OWLClassAssertionAxiom(org.semanticweb.owlapi.model.OWLClassAssertionAxiom) OWLAxiomVisitorAdapter(org.semanticweb.owlapi.util.OWLAxiomVisitorAdapter)

Aggregations

OWLClassExpression (org.semanticweb.owlapi.model.OWLClassExpression)6 OWLOntology (org.semanticweb.owlapi.model.OWLOntology)4 HashSet (java.util.HashSet)3 IRI (org.semanticweb.owlapi.model.IRI)3 OWLIndividual (org.semanticweb.owlapi.model.OWLIndividual)3 OWLNamedIndividual (org.semanticweb.owlapi.model.OWLNamedIndividual)3 HashMap (java.util.HashMap)2 OWLAxiom (org.semanticweb.owlapi.model.OWLAxiom)2 OWLAxiomVisitor (org.semanticweb.owlapi.model.OWLAxiomVisitor)2 OWLClassAssertionAxiom (org.semanticweb.owlapi.model.OWLClassAssertionAxiom)2 OWLDataFactory (org.semanticweb.owlapi.model.OWLDataFactory)2 OWLObjectPropertyAssertionAxiom (org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom)2 OWLObjectPropertyExpression (org.semanticweb.owlapi.model.OWLObjectPropertyExpression)2 OWLOntologyManager (org.semanticweb.owlapi.model.OWLOntologyManager)2 OWLAxiomVisitorAdapter (org.semanticweb.owlapi.util.OWLAxiomVisitorAdapter)2 InputStream (java.io.InputStream)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 RegistryContentException (org.apache.stanbol.ontologymanager.registry.api.RegistryContentException)1 Registry (org.apache.stanbol.ontologymanager.registry.api.model.Registry)1