Package org.mindswap.pellet.owlapi

Examples of org.mindswap.pellet.owlapi.Reasoner


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

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

    Reasoner reasoner = new Reasoner( OWL.manager );
    reasoner.setOntology( ont );

    OWLClass DreamTeamMember = Class( ns + "DreamTeamMember" );
    OWLClass DreamTeamMember1 = Class( ns + "DreamTeamMember1" );
    OWLClass DreamTeamMember2 = Class( ns + "DreamTeamMember2" );

    OWLIndividual Alice = Individual( ns + "Alice" );
    OWLIndividual Bob = Individual( ns + "Bob" );
    OWLIndividual Charlie = Individual( ns + "Charlie" );

    for( int test = 0; test < 1; test++ ) {
      if( test != 0 )
        reasoner.realise();

      assertIteratorValues( reasoner.getIndividuals( DreamTeamMember, false ).iterator(),
          new Object[] { Alice, Bob, Charlie } );

      assertIteratorValues( reasoner.getIndividuals( DreamTeamMember1, false ).iterator(),
          new Object[] { Alice, Bob, Charlie } );

      assertIteratorValues( reasoner.getIndividuals( DreamTeamMember2, false ).iterator(),
          new Object[] { Alice, Bob, Charlie } );
    }
  }
View Full Code Here


    OWLOntology ont = getOntologyFromAxioms( transitive( p1 ),
        classAssertion( x, all( p1, C ) ), propertyAssertion( x, p1, y ),
        propertyAssertion( y, p1, z ) );

    Reasoner reasoner = new Reasoner( OWL.manager );
    reasoner.setOntology( ont );

    assertTrue( reasoner.hasType( y, C ) );
    assertTrue( reasoner.hasType( z, C ) );

    OWLAxiom[] axioms = new OWLAxiom[] {
        functional( p1 ), inverseFunctional( p1 ), irreflexive( p1 ), asymmetric( p1 ),
        disjointProperties( p1, p2 ), subClassOf( C, min( p1, 2 ) ),
        classAssertion( x, max( p1, 3 ) ), disjointClasses( C, min( p1, 2 ) ) };

    for( int i = 0; i < axioms.length; i++ ) {
      addAxioms( ont, axioms[i] );

      reasoner = new Reasoner( OWL.manager );
      reasoner.setOntology( ont );
      assertTrue( axioms[i].toString(), reasoner.isEntailed( classAssertion( y, C ) ) );
      assertFalse( axioms[i].toString(), reasoner.isEntailed( classAssertion( z, C ) ) );

      removeAxioms( ont, axioms[i] );
    }
  }
View Full Code Here

  @Test
  public void testInvalidTransitivity2() throws OWLOntologyCreationException {
    OWLOntology ont = loadOntology( base + "invalidTransitivity.owl" );

    Reasoner reasoner = new Reasoner( OWL.manager );
    reasoner.setOntology( ont );

    KnowledgeBase kb = reasoner.getKB();
    kb.prepare();

    for( Role r : kb.getRBox().getRoles() ) {
      if( !ATermUtils.isBuiltinProperty( r.getName() ) ) {
        assertTrue( r.toString(), r.isSimple() );
View Full Code Here

    axioms.add( propertyAssertion( a, q, c ) );

    OWLOntology ont = getOntologyFromAxioms( axioms, ontURI );

    Reasoner reasoner = new Reasoner( OWL.manager );

    reasoner.loadOntology( ont );

    assertEquals( reasoner.getSameAsIndividuals( a ), Collections.emptySet() );
    assertEquals( reasoner.getSameAsIndividuals( b ), Collections.singleton( c ) );
    assertEquals( reasoner.getSameAsIndividuals( c ), Collections.singleton( b ) );

    assertEquals( reasoner.getObjectPropertyRelationships( a ).get( p ), SetUtils.create( b, c ) );

    assertEquals( reasoner.getObjectPropertyRelationships( a ).get( q ), SetUtils.create( b, c ) );

    assertEquals( reasoner.getObjectPropertyRelationships( b ).get( p ), SetUtils.create( b, c ) );

    assertEquals( reasoner.getObjectPropertyRelationships( b ).get( q ), SetUtils.create( a ) );

    assertEquals( reasoner.getObjectPropertyRelationships( c ).get( p ), SetUtils.create( b, c ) );

    assertEquals( reasoner.getObjectPropertyRelationships( c ).get( q ), SetUtils.create( a ) );

  }
View Full Code Here

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

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

    Reasoner reasoner = new Reasoner( OWL.manager );
    reasoner.setOntology( ont );

    OWLClass C = Class( ns + "C" );
    OWLClass D = Class( ns + "D" );
    OWLClass D1 = Class( ns + "D1" );
    OWLClass D2 = Class( ns + "D2" );
    OWLClass D3 = Class( ns + "D3" );

    OWLClass test1 = Class( ns + "test1" );
    OWLClass test2 = Class( ns + "test2" );
    OWLClass test3 = Class( ns + "test3" );

    OWLClass OlderThan10 = Class( ns + "OlderThan10" );
    OWLClass YoungerThan20 = Class( ns + "YoungerThan20" );
    OWLClass Teenager = Class( ns + "Teenager" );
    OWLClass Teen = Class( ns + "Teen" );

    OWLIndividual ind1 = Individual( ns + "ind1" );
    OWLIndividual ind3 = Individual( ns + "ind3" );
    OWLIndividual ind4 = Individual( ns + "ind4" );
    OWLIndividual ind5 = Individual( ns + "ind5" );
    OWLIndividual ind6 = Individual( ns + "ind6" );

    OWLObjectProperty p = ObjectProperty( ns + "p" );
    OWLObjectProperty r = ObjectProperty( ns + "r" );
    OWLObjectProperty invR = ObjectProperty( ns + "invR" );
    OWLObjectProperty ir = ObjectProperty( ns + "ir" );
    OWLObjectProperty as = ObjectProperty( ns + "as" );
    OWLObjectProperty d1 = ObjectProperty( ns + "d1" );
    OWLObjectProperty d2 = ObjectProperty( ns + "d2" );

    assertTrue( reasoner.isConsistent() );

    assertTrue( reasoner.isReflexive( r ) );
    assertTrue( reasoner.isReflexive( invR ) );
    assertTrue( reasoner.isIrreflexive( ir ) );
    assertTrue( reasoner.isAntiSymmetric( as ) );

    assertTrue( reasoner.isEquivalentClass( D, or( D1, D2, D3 ) ) );
    assertTrue( reasoner.isEquivalentClass( D, test1 ) );
    assertTrue( reasoner.isDisjointWith( D1, D2 ) );
    assertTrue( reasoner.isDisjointWith( D1, D3 ) );
    assertTrue( reasoner.isDisjointWith( D2, D3 ) );

    assertTrue( reasoner.isDisjointWith( d1, d2 ) );
    assertTrue( reasoner.isDisjointWith( d2, d1 ) );
    assertFalse( reasoner.isDisjointWith( p, r ) );

    assertTrue( reasoner.hasObjectPropertyRelationship( ind1, r, ind1 ) );
    assertTrue( reasoner.hasObjectPropertyRelationship( ind1, invR, ind1 ) );
    assertTrue( reasoner.isDifferentFrom( ind1, ind3 ) );
    assertTrue( reasoner.isDifferentFrom( ind1, ind4 ) );
    assertTrue( reasoner.isDifferentFrom( ind5, ind6 ) );
    assertTrue( reasoner.hasObjectPropertyRelationship( ind1, p, ind1 ) );
    assertTrue( reasoner.hasType( ind1, test2 ) );
    assertTrue( reasoner.hasType( ind1, test3 ) );
    assertIteratorValues( SetUtils.union( reasoner.getTypes( ind1, false ) ).iterator(),
        new Object[] { OWL.Thing, C, test2, test3 } );

    assertTrue( reasoner.isSubClassOf( Teenager, OlderThan10 ) );
    assertTrue( reasoner.isSubClassOf( Teenager, YoungerThan20 ) );
    assertTrue( reasoner.isEquivalentClass( Teenager, Teen ) );
    System.out.println( reasoner.getDataProperties() );
    assertTrue( reasoner.getDataProperties().contains( DataProperty( Namespaces.OWL + "topDataProperty") ) );
    assertTrue( reasoner.getDataProperties().contains( DataProperty( Namespaces.OWL + "bottomDataProperty") ) );
    assertTrue( reasoner.getObjectProperties().contains( ObjectProperty( Namespaces.OWL + "topObjectProperty") ) );
    assertTrue( reasoner.getObjectProperties().contains( ObjectProperty( Namespaces.OWL + "bottomObjectProperty") ) );
  }
View Full Code Here

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

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

    Reasoner reasoner = new Reasoner( OWL.manager );
    reasoner.setOntology( ont );

    OWLIndividual Bob = Individual( ns + "Bob" );
    OWLIndividual Sam = Individual( ns + "Sam" );

    OWLObjectProperty uncleOf = ObjectProperty( ns + "uncleOf" );
View Full Code Here

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

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

    Reasoner reasoner = new Reasoner( OWL.manager );
    reasoner.setOntology( ont );

    OWLIndividual Bob = Individual( ns + "Bob" );
    OWLIndividual John = Individual( ns + "John" );
    OWLIndividual Jane = Individual( ns + "Jane" );
View Full Code Here

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

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

    Reasoner reasoner = new Reasoner( OWL.manager );
    reasoner.setOntology( ont );

    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" );

    OWLIndividual[] a = new OWLIndividual[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.isTransitive( r ) );
    assertFalse( reasoner.isTransitive( s ) );

    assertIteratorValues( reasoner.getIndividuals( C, false ).iterator(), theList );

    assertIteratorValues( reasoner.getIndividuals( S0, false ).iterator(), theList );

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

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

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

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

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

  }
View Full Code Here

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

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

    Reasoner reasoner = new Reasoner( OWL.manager );
    reasoner.setOntology( ont );

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

    assertTrue( reasoner.isConsistent() );

    assertTrue( reasoner.isSubClassOf( sub, sup ) );
    assertTrue( reasoner.getDescendantClasses( sup ).contains( SetUtils.singleton( sub ) ) );
    assertTrue( reasoner.getAncestorClasses( sub ).contains( SetUtils.singleton( 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" );

    Reasoner reasoner = new Reasoner( OWL.manager );
    reasoner.setOntology( ont );

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

    OWLIndividual[] people = new OWLIndividual[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.hasObjectPropertyRelationship(
            people[i], knows[j], people[i] ) );

        assertIteratorValues( reasoner.getRelatedIndividuals( people[i], knows[j] )
            .iterator(), new OWLIndividual[] { people[i] } );
      }
    }

    Map<OWLIndividual, Set<OWLIndividual>> result = reasoner.getObjectPropertyAssertions( knows[0] );
    for( int i = 0; i < people.length; i++ ) {
      assertEquals("Expected property value not found: " + people[i], Collections.singleton(people[i]), result.remove(people[i]));
    }
    assertTrue("Unexpected property value: " + result, result.isEmpty());
  }
View Full Code Here

TOP

Related Classes of org.mindswap.pellet.owlapi.Reasoner

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.