Examples of OWLAnonymousIndividual


Examples of org.semanticweb.owlapi.model.OWLAnonymousIndividual

    @Test
    public void shouldParse() throws Exception {
        OWLOntology o = m.createOntology(IRI.create("urn:test"));
        OWLClass c = df.getOWLClass(IRI.create("urn:c"));
        OWLObjectProperty p = df.getOWLObjectProperty(IRI.create("urn:p"));
        OWLAnonymousIndividual i = df.getOWLAnonymousIndividual();
        OWLSubClassOfAxiom sub = df.getOWLSubClassOfAxiom(c,
                df.getOWLObjectHasValue(p, i));
        o.getOWLOntologyManager().addAxiom(o, sub);
        OWLOntology roundtrip = roundTrip(o, new OWLXMLDocumentFormat());
        equal(o, roundtrip);
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLAnonymousIndividual

    @Nonnull
    @Override
    protected Set<? extends OWLAxiom> createAxioms() {
        Set<OWLAxiom> axioms = new HashSet<>();
        OWLAnonymousIndividual ind = AnonymousIndividual();
        axioms.add(ObjectPropertyAssertion(ObjectProperty(iri("p")),
                NamedIndividual(iri("i1")), ind));
        axioms.add(ObjectPropertyAssertion(ObjectProperty(iri("p")), ind,
                NamedIndividual(iri("i2"))));
        return axioms;
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLAnonymousIndividual

                .create("http://example.com/ns#pred"));
        Set<OWLAnonymousIndividual> anonymousIndividualSet = oo
                .getAnonymousIndividuals();
        assertEquals("should be one anonymous individual", 1,
                anonymousIndividualSet.size());
        @SuppressWarnings("null")
        @Nonnull
        OWLAnonymousIndividual anonymousIndividual = anonymousIndividualSet
                .iterator().next();
        OWLAnnotationAssertionAxiom relAx = df.getOWLAnnotationAssertionAxiom(
                relProperty, IRI.create("http://example.com/ns#test"),
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLAnonymousIndividual

            // conditions on root. If that is not possible, an error is thrown.
            Set<Set<OWLAnonymousIndividual>> components=getComponents();
            Map<Set<OWLAnonymousIndividual>,OWLAnonymousIndividual> componentsToRoots=findSuitableRoots(components);
            // It seems the forest is valid, so we can read off the concepts.
            for (Set<OWLAnonymousIndividual> component : componentsToRoots.keySet()) {
                OWLAnonymousIndividual root=componentsToRoots.get(component);
                if (!specialOPEdges.containsKey(root)) {
                    // It was not possible to find a root that has exactly one relationship with a named individual,
                    // otherwise findSuitableRoots() had given preference to that root.
                    // We have to roll-up into a concept.
                    OWLClassExpression c=getClassExpressionFor(factory,root,null);
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLAnonymousIndividual

            Map<Set<OWLAnonymousIndividual>,OWLAnonymousIndividual> componentsToRoots=new HashMap<Set<OWLAnonymousIndividual>,OWLAnonymousIndividual>();
            for (Set<OWLAnonymousIndividual> component : components) {
                // We have to find a node with at most one relation to the named individuals
                // if there is one with exactly one relation that is a bit nicer for the rolling-up
                // so we try to find that
                OWLAnonymousIndividual root=null;
                OWLAnonymousIndividual rootWithOneNamedRelation=null;
                for (OWLAnonymousIndividual ind : component) {
                    if (specialOPEdges.containsKey(ind)) {
                        if (specialOPEdges.get(ind).size()<2) {
                            rootWithOneNamedRelation=ind;
                        }
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLAnonymousIndividual

                    sub=obj;
                    obj=tmp;
                    ope=ope.getInverseProperty().getSimplified();
                }
                OWLNamedIndividual named=obj.asOWLNamedIndividual();
                OWLAnonymousIndividual unnamed=sub.asOWLAnonymousIndividual();
                namedNodes.add(named);
                nodes.add(unnamed);
                if (specialOPEdges.containsKey(unnamed)) {
                    Map<OWLNamedIndividual,Set<OWLObjectPropertyExpression>> specialEdges=specialOPEdges.get(unnamed);
                    if (specialEdges.containsKey(named)) {
                        specialEdges.get(named).add(ope);
                    }
                    else {
                        specialEdges=new HashMap<OWLNamedIndividual,Set<OWLObjectPropertyExpression>>();
                        Set<OWLObjectPropertyExpression> label=new HashSet<OWLObjectPropertyExpression>();
                        label.add(ope);
                        specialEdges.put(named,label);
                        specialOPEdges.put(unnamed,specialEdges);
                    }
                }
                else {
                    Map<OWLNamedIndividual,Set<OWLObjectPropertyExpression>> specialEdge=new HashMap<OWLNamedIndividual,Set<OWLObjectPropertyExpression>>();
                    Set<OWLObjectPropertyExpression> label=new HashSet<OWLObjectPropertyExpression>();
                    label.add(ope);
                    specialEdge.put(named,label);
                    specialOPEdges.put(unnamed,specialEdge);
                }
            }
            else {
                // both sub and obj anonymous
                OWLObjectProperty op;
                if (ope.isAnonymous()) {
                    // inverse role
                    op=ope.getNamedProperty();
                    OWLIndividual tmp=sub;
                    sub=obj;
                    obj=tmp;
                }
                else {
                    op=ope.asOWLObjectProperty();
                }
                OWLAnonymousIndividual subAnon=sub.asOWLAnonymousIndividual();
                OWLAnonymousIndividual objAnon=obj.asOWLAnonymousIndividual();
                nodes.add(subAnon);
                nodes.add(objAnon);
                if ((edges.containsKey(subAnon)&&edges.get(subAnon).contains(objAnon))||((edges.containsKey(objAnon)&&edges.get(objAnon).contains(subAnon)))) {
                    throw new IllegalArgumentException("Invalid input ontology: There are two object property assertions for the same anonymous individuals, "+"which is not allowed (see OWL 2 Syntax Sec 11.2). ");
                }
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLAnonymousIndividual

        }
        public void visit(OWLDataPropertyAssertionAxiom axiom) {
            if (!axiom.getSubject().isAnonymous()) {
                return; // not interesting for the anonymous individual forest
            }
            OWLAnonymousIndividual sub=axiom.getSubject().asOWLAnonymousIndividual();
            nodes.add(sub);
            OWLClassExpression c=factory.getOWLDataHasValue(axiom.getProperty(),axiom.getObject());
            if (nodelLabels.containsKey(sub)) {
                nodelLabels.get(sub).add(c);
            }
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLAnonymousIndividual

        throw new OWLRuntimeException("Not a named individual! This method should only be called on named individuals");
    }

    @Override
  protected int compareObjectOfSameType(OWLObject object) {
        OWLAnonymousIndividual other = (OWLAnonymousIndividual) object;
        return nodeId.compareTo(other.getID());
    }
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLAnonymousIndividual

                    return ((IRI) val).toString();
                } else if (val instanceof OWLLiteral) {
                    OWLLiteral lit = (OWLLiteral) val;
                    return lit.getLiteral();
                } else if (val instanceof OWLAnonymousIndividual) {
                    OWLAnonymousIndividual ind = (OWLAnonymousIndividual) val;
                    return ind.toStringID();
                } else {
                    throw new RuntimeException("Unexpected class "
                            + val.getClass());
                }
            }
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLAnonymousIndividual

                    return ((IRI) val).toString();
                } else if (val instanceof OWLLiteral) {
                    OWLLiteral lit = (OWLLiteral) val;
                    return lit.getLiteral();
                } else if (val instanceof OWLAnonymousIndividual) {
                    OWLAnonymousIndividual ind = (OWLAnonymousIndividual) val;
                    return ind.toStringID();
                } else {
                    throw new RuntimeException("Unexpected class "
                            + val.getClass());
                }
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.