Package com.clarkparsia.pellet.owlapiv3

Examples of com.clarkparsia.pellet.owlapiv3.AxiomConverter


  public void testPropertyChain() throws OWLException {
    String ns = "http://www.example.org/test#";

    OWLOntology ont = loadOntology( base + "propertyChain.owl" );

    PelletReasoner reasoner = PelletReasonerFactory.getInstance().createReasoneront );

    OWLClass C = Class( ns + "C" );
    OWLClass S0 = Class( ns + "S0" );
    OWLClass R0 = Class( ns + "R0" );
    OWLClass R1 = Class( ns + "R1" );
    OWLObjectProperty r = ObjectProperty( ns + "r" );
    OWLObjectProperty s = ObjectProperty( ns + "s" );

    OWLNamedIndividual[] a = new OWLNamedIndividual[17];
    for( int i = 0; i < a.length; i++ ) {
          a[i] = Individual( ns + "a" + i );
        }

    OWLIndividual[] theList = new OWLIndividual[] {
        a[1], a[2], a[3], a[4], a[5], a[6], a[8], a[10], a[12], a[14], a[16] };

    assertTrue( reasoner.isConsistent() );

    assertTrue( reasoner.isEntailed( OWL.transitive( r ) ) );
    assertFalse( reasoner.isEntailed( OWL.transitive( s ) ) );

    assertIteratorValues( reasoner.getInstances( C, false ).getFlattened().iterator(), theList );

    assertIteratorValues( reasoner.getInstances( S0, false ).getFlattened().iterator(), theList );

    assertIteratorValues( reasoner.getInstances( R0, false ).getFlattened().iterator(), new OWLIndividual[] {
        a[7], a[9] } );

    assertIteratorValues( reasoner.getInstances( R1, false ).getFlattened().iterator(), new OWLIndividual[] {
        a[2], a[3], a[4], a[5], a[6] } );

    assertIteratorValues( reasoner.getObjectPropertyValues( a[0], r ).getFlattened().iterator(),
        new OWLIndividual[] { a[7], a[9] } );

    assertIteratorValues( reasoner.getObjectPropertyValues( a[1], r ).getFlattened().iterator(),
        new OWLIndividual[] { a[2], a[3], a[4], a[5], a[6] } );

    assertIteratorValues( reasoner.getObjectPropertyValues( a[0], s ).getFlattened().iterator(), theList );

  }
View Full Code Here


  public void testQualifiedCardinality1() throws OWLException {
    String ns = "http://www.example.org/test#";

    OWLOntology ont = loadOntology( base + "qcr.owl" );

    PelletReasoner reasoner = PelletReasonerFactory.getInstance().createReasoner( ont );

    OWLClass sub = Class( ns + "sub" );
    OWLClass sup = Class( ns + "sup" );

    assertTrue( reasoner.isConsistent() );

    assertTrue( reasoner.isEntailed( subClassOf( sub, sup ) ) );
    assertTrue( reasoner.getSubClasses( sup, false ).getFlattened().contains( sub ) );
    assertTrue( reasoner.getSuperClasses( sub, false ).getFlattened().contains( sup ) );
  }
View Full Code Here

    String ns = "http://www.example.org/test#";
    String foaf = "http://xmlns.com/foaf/0.1/";

    OWLOntology ont = loadOntology( base + "reflexive.owl" );

    PelletReasoner reasoner = PelletReasonerFactory.getInstance().createReasoner( ont );

    OWLObjectProperty[] knows = {
        ObjectProperty( foaf + "knows" ), ObjectProperty( ns + "knows2" ),
        ObjectProperty( ns + "knows3" ) };

    OWLNamedIndividual[] people = new OWLNamedIndividual[5];
    for( int i = 0; i < people.length; i++ ) {
      people[i] = Individual( ns + "P" + (i + 1) );

      for( int j = 0; j < knows.length; j++ ) {
        assertTrue( people[i] + " " + knows[j], reasoner.isEntailed( propertyAssertion(
            people[i], knows[j], people[i] ) ) );

        assertPropertyValues( reasoner, people[i], knows[j], people[i] );
      }
    }
View Full Code Here

  @Test
  public void testInfiniteChain() throws Exception {
    OWLOntology ont = loadOntology( base + "infiniteChain.owl" );

    PelletReasoner reasoner = PelletReasonerFactory.getInstance().createReasoner( ont );

    assertTrue( !reasoner.isConsistent() );
  }
View Full Code Here

  public void testRemoveLiteral(String indName, boolean buffering) throws Exception {
    String ns = "http://www.example.org/test#";

    OWLOntology ont = loadOntology( base + "RemoveLiteral.owl" );

    PelletReasoner reasoner = buffering
      ? PelletReasonerFactory.getInstance().createReasoner( ont )
      : PelletReasonerFactory.getInstance().createNonBufferingReasoner( ont );

    OWLDataProperty pInt = DataProperty( ns + "pInt" );
    OWLDataProperty pDouble = DataProperty( ns + "pDouble" );
    OWLDataProperty pBoolean = DataProperty( ns + "pBoolean" );

    OWLNamedIndividual ind = Individual( ns + indName );

    OWLLiteral valDouble = ind.getDataPropertyValues( pDouble, ont ).iterator().next();
    OWLLiteral valInt = ind.getDataPropertyValues( pInt, ont ).iterator().next();
    OWLLiteral valBoolean = ind.getDataPropertyValues( pBoolean, ont ).iterator().next();

    assertTrue( reasoner.isConsistent() );
   
    removeAxioms(ont, propertyAssertion( ind, pDouble, valDouble ) );
    if( buffering ) {
      assertFalse( reasoner.getDataPropertyValues( ind, pDouble ).isEmpty() );
      reasoner.flush();
    }
    assertTrue( reasoner.getDataPropertyValues( ind, pDouble ).isEmpty() );

    removeAxioms( ont, propertyAssertion( ind, pInt, valInt ) );
    if( buffering ) {
      assertFalse( reasoner.getDataPropertyValues( ind, pInt ).isEmpty() );
      reasoner.flush();
    }
    assertTrue( reasoner.getDataPropertyValues( ind, pInt ).isEmpty() );

    removeAxioms( ont, propertyAssertion( ind, pBoolean, valBoolean ) );
    if( buffering ) {
      assertFalse( reasoner.getDataPropertyValues( ind, pBoolean ).isEmpty() );
      reasoner.flush();
    }
    assertTrue( reasoner.getDataPropertyValues( ind, pBoolean ).isEmpty() );

    // assertTrue( reasoner.getDataPropertyRelationships( ind ).isEmpty() );

    OWLLiteral newVal = constant( "0.0", XSD.DOUBLE );
    addAxioms( ont, propertyAssertion( ind, pDouble, newVal ) );
    if( buffering ) {
          reasoner.flush();
        }

    assertTrue( reasoner.isConsistent() );
  }
View Full Code Here

    OWLOntology ont = loadOntology( base + "family.owl" );
    for (OWLAxiom axiom : ont.getAxioms()) {
      System.out.println(axiom);         
        }

    PelletReasoner reasoner = PelletReasonerFactory.getInstance().createReasoner( ont );
   
    try {
          testFamily( ns, reasoner );
         
          reasoner.getKB().realize();
         
          testFamily( ns, reasoner );
        }
        finally {
        reasoner.dispose();
        }
  }
View Full Code Here

    OWLClass C = Class( ns + "C" );
    OWLClass D = Class( ns + "D" );
    OWLObjectProperty r = ObjectProperty( ns + "r" );
    OWLClassExpression desc = some( inverse( r ), D );

    PelletReasoner reasoner = PelletReasonerFactory.getInstance().createReasoner( ont );

    assertEquals( Collections.singleton( C ), reasoner
        .getSubClasses( desc, true ).getFlattened() );

    assertTrue( reasoner.isEntailed( inverseFunctional( ObjectProperty( ns + "functionalP" ) ) ) );

    assertTrue( reasoner.isEntailed( functional( ObjectProperty( ns + "inverseFunctionalP" ) ) ) );

    assertTrue( reasoner.isEntailed( transitive( ObjectProperty( ns + "transitiveP" ) ) ) );

    assertTrue( reasoner.isEntailed( symmetric( ObjectProperty( ns + "symmetricP" ) ) ) );

    assertTrue( reasoner.isEntailed( reflexive( ObjectProperty( ns + "reflexiveP" ) ) ) );

    assertTrue( reasoner.isEntailed( irreflexive( ObjectProperty( ns + "irreflexiveP" ) ) ) );

    assertTrue( reasoner.isEntailed( asymmetric( ObjectProperty( ns + "asymmetricP" ) ) ) );

    OWLObjectProperty p1 = ObjectProperty( ns + "p1" );
    OWLObjectProperty p2 = ObjectProperty( ns + "p2" );
    OWLObjectProperty p3 = ObjectProperty( ns + "p3" );
    assertTrue( reasoner.isEntailed( equivalentProperties( p1, p2 ) ) );
    assertTrue( reasoner.isEntailed( equivalentProperties( p1, p3 ) ) );
    assertTrue( reasoner.isEntailed( equivalentProperties( p2, p3 ) ) );
  }
View Full Code Here

  public void testDLSafeRules() throws OWLOntologyCreationException {
    String ns = "http://owldl.com/ontologies/dl-safe.owl#";

    OWLOntology ont = loadOntology( base + "dl-safe.owl" );

    PelletReasoner reasoner = PelletReasonerFactory.getInstance().createReasoner( ont );

    // OWLObjectProperty father = factory.getOWLObjectProperty( URI.create(
    // ns + "father" ) );
    OWLObjectProperty hates = ObjectProperty( ns + "hates" );
    OWLObjectProperty sibling = ObjectProperty( ns + "sibling" );

    OWLClass BadChild = Class( ns + "BadChild" );
    OWLClass Child = Class( ns + "Child" );
    // OWLClass GoodChild = Class( ns +
    // "GoodChild" );
    OWLClass Grandchild = Class( ns + "Grandchild" );
    OWLClass Person = Class( ns + "Person" );

    OWLNamedIndividual Abel = Individual( ns + "Abel" );
    OWLNamedIndividual Cain = Individual( ns + "Cain" );
    OWLNamedIndividual Oedipus = Individual( ns + "Oedipus" );
    OWLNamedIndividual Remus = Individual( ns + "Remus" );
    OWLNamedIndividual Romulus = Individual( ns + "Romulus" );

    for( int test = 0; test < 2; test++ ) {
      if( test != 0 ) {
              reasoner.prepareReasoner();
            }

      assertTrue( reasoner.isEntailed( propertyAssertion( Abel, sibling, Cain ) ) );

      assertPropertyValues( reasoner, Abel, sibling, Cain);

      assertTrue( reasoner.isEntailed( propertyAssertion( Cain, sibling, Abel ) ) );

      assertPropertyValues( reasoner, Cain, sibling, Abel );

      assertTrue( reasoner.isEntailed( propertyAssertion( Cain, hates, Abel ) ) );

      assertFalse( reasoner.isEntailed( propertyAssertion( Abel, hates, Cain ) ) );

      assertTrue( reasoner.isEntailed( classAssertion( Cain, Grandchild ) ) );

      assertTrue( reasoner.isEntailed( classAssertion( Cain, BadChild ) ) );

      assertFalse( reasoner.isEntailed( propertyAssertion( Romulus, sibling, Remus ) ) );

      assertTrue( reasoner.isEntailed( classAssertion( Romulus, Grandchild ) ) );

      assertFalse( reasoner.isEntailed( classAssertion( Romulus, BadChild ) ) );

      assertTrue( reasoner.isEntailed( classAssertion( Oedipus, Child ) ) );
    }

    assertIteratorValues( reasoner.getTypes( Cain, true ).getFlattened().iterator(),
        new Object[] { BadChild, Child, Person } );
  }
View Full Code Here

    Set<OWLAxiom> axioms = new HashSet<OWLAxiom>();
    axioms.add(manager.getOWLDataFactory().getOWLSubAnnotationPropertyOfAxiom(op1, op2));
    axioms.add(manager.getOWLDataFactory().getOWLAnnotationAssertionAxiom( op1 , oi.getIRI(), oo1 ));
   
    OWLOntology ontology = manager.createOntology(axioms);
    PelletReasoner reasoner = PelletReasonerFactory.getInstance().createReasoner(ontology);
   
    assertEquals(reasoner.getAnnotationPropertyValues(oi, op1), reasoner.getAnnotationPropertyValues(oi, op2));
  }
View Full Code Here

    axioms.add(manager.getOWLDataFactory().getOWLSubAnnotationPropertyOfAxiom(op1, op2));
    axioms.add(manager.getOWLDataFactory().getOWLSubAnnotationPropertyOfAxiom(op2, op3));
    axioms.add(manager.getOWLDataFactory().getOWLAnnotationAssertionAxiom( op1 , oi.getIRI(), oo1 ));
       
    OWLOntology ontology = manager.createOntology(axioms);
    PelletReasoner reasoner = PelletReasonerFactory.getInstance().createReasoner(ontology);
   
    assertEquals(reasoner.getAnnotationPropertyValues(oi, op1), reasoner.getAnnotationPropertyValues(oi, op3));
  }
View Full Code Here

TOP

Related Classes of com.clarkparsia.pellet.owlapiv3.AxiomConverter

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.