Package org.semanticweb.owlapi.model

Examples of org.semanticweb.owlapi.model.OWLDataFactory


            if (node==null)
                node=new HierarchyNode<AtomicConcept>(atomicConcept,Collections.singleton(atomicConcept),Collections.singleton(m_atomicConceptHierarchy.getTopNode()),Collections.singleton(m_atomicConceptHierarchy.getBottomNode()));
            return node;
        }
        else {
            OWLDataFactory factory=getDataFactory();
            OWLClass queryConcept=factory.getOWLClass(IRI.create("internal:query-concept"));
            OWLAxiom classDefinitionAxiom=factory.getOWLEquivalentClassesAxiom(queryConcept,classExpression);
            final Tableau tableau=getTableau(classDefinitionAxiom);
            HierarchySearch.Relation<AtomicConcept> hierarchyRelation=new HierarchySearch.Relation<AtomicConcept>() {
                public boolean doesSubsume(AtomicConcept parent,AtomicConcept child) {
                    Individual freshIndividual=Individual.createAnonymous("fresh-individual");
                    return !tableau.isSatisfiable(true,Collections.singleton(Atom.create(child,freshIndividual)),null,null,Collections.singleton(Atom.create(parent,freshIndividual)),null,ReasoningTaskDescription.isConceptSubsumedBy(child,parent));
View Full Code Here


            else {
                Map<Role,AtomicConcept> conceptsForRoles=new HashMap<Role,AtomicConcept>();
                final Map<AtomicConcept,Role> rolesForConcepts=new HashMap<AtomicConcept,Role>();
                // Create the additional axioms for classification
                List<OWLAxiom> additionalAxioms=new ArrayList<OWLAxiom>();
                OWLDataFactory factory=getDataFactory();
                OWLClass freshConcept=factory.getOWLClass(IRI.create("internal:fresh-concept"));
                for (Role objectRole : relevantObjectRoles) {
                    AtomicConcept conceptForRole;
                    OWLObjectPropertyExpression objectPropertyExpression;
                    if (objectRole instanceof AtomicRole) {
                        conceptForRole=AtomicConcept.create("internal:prop#"+((AtomicRole)objectRole).getIRI());
                        objectPropertyExpression=factory.getOWLObjectProperty(IRI.create(((AtomicRole)objectRole).getIRI()));
                    }
                    else {
                        conceptForRole=AtomicConcept.create("internal:prop#inv#"+((InverseRole)objectRole).getInverseOf().getIRI());
                        objectPropertyExpression=factory.getOWLObjectInverseOf(factory.getOWLObjectProperty(IRI.create(((InverseRole)objectRole).getInverseOf().getIRI())));
                    }
                    OWLClass classForRole=factory.getOWLClass(IRI.create(conceptForRole.getIRI()));
                    OWLAxiom axiom=factory.getOWLEquivalentClassesAxiom(classForRole,factory.getOWLObjectSomeValuesFrom(objectPropertyExpression,freshConcept));
                    additionalAxioms.add(axiom);
                    conceptsForRoles.put(objectRole,conceptForRole);
                    rolesForConcepts.put(conceptForRole,objectRole);
                }
                OWLAxiom[] additionalAxiomsArray=new OWLAxiom[additionalAxioms.size()];
View Full Code Here

        if (m_objectRoleHierarchy!=null && !containsFreshEntities(subObjectPropertyExpression,superObjectPropertyExpression)) {
            HierarchyNode<Role> subroleNode=m_objectRoleHierarchy.getNodeForElement(subrole);
            return subroleNode.isEquivalentElement(superrole) || subroleNode.isAncestorElement(superrole);
        }
        else {
            OWLDataFactory factory=getDataFactory();
            OWLClass pseudoNominal=factory.getOWLClass(IRI.create("internal:pseudo-nominal"));
            OWLClassExpression allSuperNotPseudoNominal=factory.getOWLObjectAllValuesFrom(superObjectPropertyExpression,pseudoNominal.getObjectComplementOf());
            OWLIndividual freshIndividualA=factory.getOWLAnonymousIndividual("fresh-individual-A");
            OWLIndividual freshIndividualB=factory.getOWLAnonymousIndividual("fresh-individual-B");
            OWLAxiom subObjectPropertyAssertion=factory.getOWLObjectPropertyAssertionAxiom(subObjectPropertyExpression,freshIndividualA,freshIndividualB);
            OWLAxiom pseudoNominalAssertion=factory.getOWLClassAssertionAxiom(pseudoNominal,freshIndividualB);
            OWLAxiom allSuperNotPseudoNominalAssertion=factory.getOWLClassAssertionAxiom(allSuperNotPseudoNominal,freshIndividualA);
            Tableau tableau=getTableau(subObjectPropertyAssertion,pseudoNominalAssertion,allSuperNotPseudoNominalAssertion);
            return !tableau.isSatisfiable(true,null,null,null,null,null,ReasoningTaskDescription.isRoleSubsumedBy(subrole,superrole,true));
        }
    }
View Full Code Here

        objects[subPropertyChain.size()]=superObjectPropertyExpression;
        checkPreConditions(objects);
        if (!m_isConsistent || superObjectPropertyExpression.getNamedProperty().isOWLTopObjectProperty())
            return true;
        else {
            OWLDataFactory factory=getDataFactory();
            OWLClass pseudoNominal=factory.getOWLClass(IRI.create("internal:pseudo-nominal"));
            OWLClassExpression allSuperNotPseudoNominal=factory.getOWLObjectAllValuesFrom(superObjectPropertyExpression,pseudoNominal.getObjectComplementOf());
            OWLAxiom[] additionalAxioms=new OWLAxiom[subPropertyChain.size()+2];
            int axiomIndex=0;
            for (OWLObjectPropertyExpression subObjectPropertyExpression : subPropertyChain) {
                OWLIndividual first=factory.getOWLAnonymousIndividual("fresh-individual-"+axiomIndex);
                OWLIndividual second=factory.getOWLAnonymousIndividual("fresh-individual-"+(axiomIndex+1));
                additionalAxioms[axiomIndex++]=factory.getOWLObjectPropertyAssertionAxiom(subObjectPropertyExpression,first,second);
            }
            OWLIndividual freshIndividual0=factory.getOWLAnonymousIndividual("fresh-individual-0");
            OWLIndividual freshIndividualN=factory.getOWLAnonymousIndividual("fresh-individual-"+subPropertyChain.size());
            additionalAxioms[axiomIndex++]=factory.getOWLClassAssertionAxiom(pseudoNominal,freshIndividualN);
            additionalAxioms[axiomIndex++]=factory.getOWLClassAssertionAxiom(allSuperNotPseudoNominal,freshIndividual0);
            Tableau tableau=getTableau(additionalAxioms);
            return !tableau.isSatisfiable(true,null,null,null,null,null,new ReasoningTaskDescription(true,"subproperty chain subsumption"));
        }
    }
View Full Code Here

    System.out.println( "\nResults after applying changes through OWL API" );
    System.out.println( "----------------------------------------------" );

    // read the ontology
    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    OWLDataFactory factory = manager.getOWLDataFactory();
    OWLOntology ontology = manager.loadOntology( IRI.create( mindswappers ) );

    // we want a non-buffering reasoner here (a buffering reasoner would not process any additions, until manually refreshed)
    PelletReasoner reasoner = com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory.getInstance().createNonBufferingReasoner( ontology );
    manager.addOntologyChangeListener( reasoner );

    // perform initial consistency check
    long s = System.currentTimeMillis();
    boolean consistent = reasoner.isConsistent();
    long e = System.currentTimeMillis();
    System.out.println( "Consistent? " + consistent + " (" + (e - s) + "ms)" );

    // peform ABox addition which results in a consistent KB
    OWLClass concept = factory.getOWLClass( IRI.create( mindswap + "GraduateStudent" ) );
    OWLNamedIndividual individual = factory
        .getOWLNamedIndividual( IRI.create( mindswappers + "JohnDoe" ) );
    manager.applyChange( new AddAxiom( ontology, factory.getOWLClassAssertionAxiom( concept, individual ) ) );

    // perform incremental consistency check
    s = System.currentTimeMillis();
    consistent = reasoner.isConsistent();
    e = System.currentTimeMillis();
    System.out.println( "Consistent? " + consistent + " (" + (e - s) + "ms)" );

    // peform ABox addition which results in an inconsistent KB
    OWLObjectProperty role = factory.getOWLObjectProperty( IRI.create( foaf + "mbox" ) );
    individual = factory.getOWLNamedIndividual( IRI.create( mindswappers + "Christian.Halaschek" ) );
    OWLNamedIndividual mbox = factory.getOWLNamedIndividual( IRI.create( "mailto:kolovski@cs.umd.edu" ) );
    manager.applyChange( new AddAxiom( ontology, factory.getOWLObjectPropertyAssertionAxiom(
        role, individual, mbox ) ) );

    // perform incremental consistency check
    s = System.currentTimeMillis();
    consistent = reasoner.isConsistent();
View Full Code Here

  public static void runWithOWLAPI() throws OWLException {
    String ont = "http://www.mindswap.org/2004/owl/mindswappers#";
   
    // create an ontology manager
    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    OWLDataFactory factory = manager.getOWLDataFactory();
   
    // read the ontology
    OWLOntology ontology = manager.loadOntology( IRI.create(ont) );
   
    // load the ontology to the reasoner
    PelletReasoner reasoner = com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory.getInstance().createReasoner( ontology );
   
    // create property and resources to query the reasoner
    OWLClass Person = factory.getOWLClass(IRI.create("http://xmlns.com/foaf/0.1/Person"));
    OWLObjectProperty workHomepage = factory.getOWLObjectProperty(IRI.create("http://xmlns.com/foaf/0.1/workInfoHomepage"));
    OWLDataProperty foafName = factory.getOWLDataProperty(IRI.create("http://xmlns.com/foaf/0.1/name"));
   
    // get all instances of Person class
    Set<OWLNamedIndividual> individuals = reasoner.getInstances( Person, false ).getFlattened();
    for(OWLNamedIndividual ind : individuals) {     
        // get the info about this specific individual
View Full Code Here

    assertTrue(extractor.getOWLClass() instanceof OWLClass);
    assertTrue(extractor.getOWLDatatype() instanceof OWLDatatype);
    assertTrue(extractor.getOWLEntity() instanceof OWLEntity);
    assertTrue(extractor.getOWLProperty() instanceof OWLProperty);
   
    OWLDataFactory factory = OWLManager.getOWLDataFactory();
    OWLDataProperty dataProperty = factory.getOWLDataProperty(IRI.create("http://example.owl#test"));
    Reasoner reasoner = new Reasoner(ontology);
    NodeSet<OWLClass> nodeSet = reasoner.getDataPropertyDomains(dataProperty, true);
    System.out.println(nodeSet);
   
    assertTrue(extractor.getOWLDataProperty() instanceof OWLDataProperty);
View Full Code Here

        OWLReasonerFactory reasonerFactory = null;
        reasonerFactory = new Reasoner.ReasonerFactory();
        OWLReasoner reasoner = reasonerFactory
            .createReasoner(ontology1);

        OWLDataFactory fac = manager.getOWLDataFactory();
        OWLClass peOutputClass = fac.getOWLClass(IRI.create(peOutput));
        OWLClass peInputClass = fac.getOWLClass(IRI.create(peInput));

        if (equivalentClasses(peOutputClass, peInputClass, ontology1,
            reasoner)) {
          mOutputBlockWriter.write("equivalent");
        } else if (subclassOf(peOutputClass, peInputClass, reasoner)) {
View Full Code Here

    return annotation;
  }

 
  public IProperty createSubProperty(String name) {
    OWLDataFactory dataFactory = getOWLDataFactory();
    OWLAnnotationProperty ch = dataFactory.getOWLAnnotationProperty(IRI.create(getOntology().getNameSpace()+name));
    addAxiom(getOWLDataFactory().getOWLSubAnnotationPropertyOfAxiom(ch,annotation));
    return (IProperty) convertOWLObject(ch);
  }
View Full Code Here

  }


 
  public void addPropertyValue(IProperty prop, Object value) {
    OWLDataFactory df = getOWLDataFactory();
    OWLIndividual subj = getOWLIndividual();
    if(prop.isAnnotationProperty()){
      super.addPropertyValue(prop, value);
    }else if(prop.isDatatypeProperty()){
      OWLDataProperty dp = (OWLDataProperty)convertOntologyObject(prop);
      OWLLiteral dl = (OWLLiteral)convertOntologyObject(value);
      addAxiom(df.getOWLDataPropertyAssertionAxiom(dp,subj,dl));
    }else if(prop.isObjectProperty()){
      OWLObjectProperty op = (OWLObjectProperty)convertOntologyObject(prop);
      OWLIndividual oo = (OWLIndividual)convertOntologyObject(value);
      addAxiom(df.getOWLObjectPropertyAssertionAxiom(op,subj,oo));
    }
  }
View Full Code Here

TOP

Related Classes of org.semanticweb.owlapi.model.OWLDataFactory

Copyright © 2018 www.massapicom. 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.