Package org.mindswap.pellet.owlapi

Examples of org.mindswap.pellet.owlapi.Reasoner$LiteralMapper


    axioms.add( classAssertion( i3, c ) );

    OWLOntology ont = getOntologyFromAxioms( axioms, ontURI );

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

    assertTrue( !reasoner.isSameAs( i1, i2 ) );
    assertTrue( !reasoner.isSameAs( i1, i3 ) );
    assertEquals( reasoner.getSameAsIndividuals( i1 ), Collections.emptySet() );

    assertTrue( !reasoner.isSameAs( i2, i1 ) );
    assertTrue( !reasoner.isSameAs( i2, i3 ) );
    assertEquals( reasoner.getSameAsIndividuals( i2 ), Collections.emptySet() );

    assertTrue( !reasoner.isSameAs( i3, i1 ) );
    assertTrue( !reasoner.isSameAs( i3, i2 ) );
    assertEquals( reasoner.getSameAsIndividuals( i2 ), Collections.emptySet() );

  }
View Full Code Here


  public void testRealizeByIndividualsNPE() throws Exception {
    PelletOptions.REALIZE_INDIVIDUAL_AT_A_TIME = false;

    ProgressMonitor monitor = new TimedProgressMonitor( 1 );

    Reasoner pellet = new Reasoner( OWL.manager );
    KnowledgeBase kb = pellet.getKB();

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

    kb.classify();

    kb.getTaxonomyBuilder().setProgressMonitor( monitor );
View Full Code Here

  // Not having timeout functionality in classification and realization makes
  // it harder to interrupt these processes
  public void testClassificationTimeout() throws Exception {
    boolean timeout = false;

    Reasoner pellet = new Reasoner( OWL.manager );
    KnowledgeBase kb = pellet.getKB();

    Timer timer = kb.timers.createTimer( "classify" );
    timer.setTimeout( 1 );

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

    try {
      kb.classify();
    } catch( TimeoutException e ) {
      timeout = true;
View Full Code Here

  // This tests ticket 147
  // Not having timeout functionality in classification and realization makes
  // it harder to interrupt these processes
  public void testRealizationTimeout() throws Exception {
    boolean timeout = false;
    Reasoner pellet = new Reasoner( OWL.manager );
    KnowledgeBase kb = pellet.getKB();

    Timer timer = kb.timers.createTimer( "realize" );
    timer.setTimeout( 1 );

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

    try {
      kb.classify();
    } catch( TimeoutException e ) {
      timeout = true;
View Full Code Here

    String src = "@prefix ex: <" + ns + "> .\r\n"
        + "@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .\r\n"
        + "@prefix owl: <http://www.w3.org/2002/07/owl#> .\r\n" + "\r\n"
        + "ex:C rdfs:subClassOf ex:D .\r\n" + "[] a ex:C .";

    Reasoner pellet = new Reasoner( OWL.manager );

    OWLOntology ont = OWL.manager.loadOntology( new StringInputSource( src ) );
    pellet.loadOntology( ont );

    OWLClass D = OWL.Class( ns + "D" );

    assertTrue( pellet.getIndividuals( D, true ).size() == 0 );

    assertTrue( pellet.getIndividuals( D, false ).size() == 1 );
  }
View Full Code Here

    assertTrue( pellet.getIndividuals( D, false ).size() == 1 );
  }
 
  @Test
  public void testTopBottomPropertyAssertion() throws OWLOntologyCreationException {
    Reasoner pellet = new Reasoner( OWL.manager );

    OWLAxiom[] axioms = {
        OWL.propertyAssertion( a, OWL.topObjectProperty, b ),
        OWL.propertyAssertion( a, OWL.topDataProperty, lit ),
        OWL.propertyAssertion( a, OWL.bottomObjectProperty, b ),
        OWL.propertyAssertion( a, OWL.bottomDataProperty, lit ) };
    for( int i = 0; i < axioms.length; i++ ) {
      OWLOntology ont = OntologyUtils.getOntologyFromAxioms( axioms[i] );
      pellet.setOntology( ont );
      assertEquals( i < 2, pellet.isConsistent() );
    }
  }
View Full Code Here

        OWL.propertyAssertion( a, p, b ),
        OWL.classAssertion( c, C ),
        OWL.propertyAssertion( a, dp, lit )
    };
   
    Reasoner pellet = new Reasoner( OWL.manager );
    OWLOntology ont = OntologyUtils.getOntologyFromAxioms( axioms );
    pellet.setOntology( ont );

   
    assertTrue( pellet.isSubPropertyOf( p, OWL.topObjectProperty ) );
    assertTrue( pellet.isSubPropertyOf( OWL.bottomObjectProperty, p ) );
    assertTrue( pellet.isSubPropertyOf( dp, OWL.topDataProperty ) );
    assertTrue( pellet.isSubPropertyOf( OWL.bottomDataProperty, dp ) );
   
    assertEquals( Collections.singleton( Collections.singleton( p ) ), pellet.getSubProperties( OWL.topObjectProperty ) );
    assertEquals( Collections.singleton( Collections.singleton( OWL.bottomObjectProperty ) ), pellet.getSubProperties( p ) );
    assertEquals( Collections.singleton( Collections.singleton( dp ) ), pellet.getSubProperties( OWL.topDataProperty ) );
    assertEquals( Collections.singleton( Collections.singleton( OWL.bottomDataProperty ) ), pellet.getSubProperties( dp ) );
   
    assertTrue( pellet.hasObjectPropertyRelationship( a, p, b ) );
    assertFalse( pellet.hasObjectPropertyRelationship( b, p, a ) );
    assertTrue( pellet.hasObjectPropertyRelationship( a, OWL.topObjectProperty, b ) );
    assertTrue( pellet.hasObjectPropertyRelationship( b, OWL.topObjectProperty, a ) );
   
    assertTrue( pellet.hasDataPropertyRelationship( a, dp, lit ) );
    assertFalse( pellet.hasDataPropertyRelationship( b, dp, lit ) );
    assertTrue( pellet.hasDataPropertyRelationship( a, OWL.topDataProperty, lit ) );
    assertTrue( pellet.hasDataPropertyRelationship( b, OWL.topDataProperty, lit ) );
   
    assertEquals( SetUtils.create( b ), pellet.getObjectPropertyRelationships( a ).get( p ) );
    assertFalse( pellet.getObjectPropertyRelationships( b ).containsKey( p ) );
    assertEquals( SetUtils.create( a, b, c ), pellet.getObjectPropertyRelationships( a ).get( OWL.topObjectProperty ) );
    assertEquals( SetUtils.create( a, b, c ), pellet.getObjectPropertyRelationships( b ).get( OWL.topObjectProperty ) );
    assertEquals( SetUtils.create( lit ), pellet.getDataPropertyRelationships( a ).get( OWL.topDataProperty ) );
    assertEquals( SetUtils.create( lit ), pellet.getDataPropertyRelationships( b ).get( OWL.topDataProperty ) );
    assertFalse( pellet.getDataPropertyRelationships( a ).containsKey( OWL.bottomObjectProperty ) );
    assertFalse( pellet.getDataPropertyRelationships( a ).containsKey( OWL.bottomDataProperty ) );
   
    assertEquals( SetUtils.create( a, b, c ), pellet.getObjectPropertyAssertions( OWL.topObjectProperty ).get( a ) );
    assertTrue( pellet.getObjectPropertyAssertions( OWL.bottomObjectProperty ).isEmpty() );
    assertEquals( SetUtils.create( lit ), pellet.getDataPropertyAssertions( OWL.topDataProperty ).get( c ) );
    assertTrue( pellet.getDataPropertyAssertions( OWL.bottomDataProperty ).isEmpty() );
   
    }
    finally {
      PelletOptions.HIDE_TOP_PROPERTY_VALUES = prevValue;
    }
View Full Code Here

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

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

    Reasoner reasoner = new Reasoner( OWL.manager );
    reasoner.loadOntologies( Collections.singleton( ont ) );
    assertTrue( reasoner.isConsistent() );

    KnowledgeBase kb = reasoner.getKB();

    assertTrue( reasoner.isDefined( Individual( ns + "a" ) ) );
    assertEquals( 1, reasoner.getIndividuals().size() );

    assertTrue( reasoner.isDefined( Class( ns + "C" ) ) );
    assertEquals( 1, reasoner.getClasses().size() );
    // FIXME: OWLAPI should support Datatype definition checking
    assertFalse( kb.isDatatype( ATermUtils.makeTermAppl( ns + "C" ) ) );

    assertFalse( reasoner.isDefined( Class( ns + "D" ) ) );
    // FIXME: OWLAPI should support Datatype definition checking
    // FIXME: OWLAPI loader does not parse Datatype declarations
    //assertTrue( kb.isDatatype( ATermUtils.makeTermAppl( ns + "D" ) ) );

    /* FIXME: There is no positive check here because OWLAPI does not support annotation property declaration. */
    assertFalse( reasoner.isDefined( DataProperty( ns + "p" ) ) );
    assertFalse( reasoner.isDefined( ObjectProperty( ns + "p" ) ) );
   
    assertTrue( reasoner.isDefined( ObjectProperty( ns + "q" ) ) );
    assertEquals( 2 + 1, reasoner.getObjectProperties().size() );
    assertFalse( kb.isAnnotationProperty( ATermUtils.makeTermAppl( ns + "r" ) ) );
    assertFalse( reasoner.isDefined( DataProperty( ns + "q" ) ) );

    assertTrue( reasoner.isDefined( DataProperty( ns + "r" ) ) );
    assertEquals( 2 + 1, reasoner.getDataProperties().size() );
    assertFalse( kb.isAnnotationProperty( ATermUtils.makeTermAppl( ns + "r" ) ) );
    assertFalse( reasoner.isDefined( ObjectProperty( ns + "r" ) ) );
  }
View Full Code Here

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

    Reasoner reasoner = new Reasoner( OWL.manager );

    reasoner.loadOntologies( Collections.singleton( ont ) );

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

    assertTrue( reasoner.isInverseFunctional( ObjectProperty( ns + "functionalP" ) ) );

    assertTrue( reasoner.isFunctional( ObjectProperty( ns + "inverseFunctionalP" ) ) );

    assertTrue( reasoner.isTransitive( ObjectProperty( ns + "transitiveP" ) ) );

    assertTrue( reasoner.isSymmetric( ObjectProperty( ns + "symmetricP" ) ) );

    assertTrue( reasoner.isReflexive( ObjectProperty( ns + "reflexiveP" ) ) );

    assertTrue( reasoner.isIrreflexive( ObjectProperty( ns + "irreflexiveP" ) ) );

    assertTrue( reasoner.isAntiSymmetric( ObjectProperty( ns + "asymmetricP" ) ) );

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

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

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

    Reasoner reasoner = new Reasoner( OWL.manager );
    reasoner.setOntology( 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" );

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

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

      assertTrue( reasoner.hasObjectPropertyRelationship( Abel, sibling, Cain ) );

      assertIteratorValues( reasoner.getRelatedIndividuals( Abel, sibling ).iterator(),
          new Object[] { Cain } );

      assertTrue( reasoner.hasObjectPropertyRelationship( Cain, sibling, Abel ) );

      assertIteratorValues( reasoner.getRelatedIndividuals( Cain, sibling ).iterator(),
          new Object[] { Abel } );

      assertTrue( reasoner.hasObjectPropertyRelationship( Cain, hates, Abel ) );

      assertFalse( reasoner.hasObjectPropertyRelationship( Abel, hates, Cain ) );

      assertTrue( reasoner.hasType( Cain, Grandchild ) );

      assertTrue( reasoner.hasType( Cain, BadChild ) );

      assertFalse( reasoner.hasObjectPropertyRelationship( Romulus, sibling, Remus ) );

      assertTrue( reasoner.hasType( Romulus, Grandchild ) );

      assertFalse( reasoner.hasType( Romulus, BadChild ) );

      assertTrue( reasoner.hasType( Oedipus, Child ) );
    }

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

TOP

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

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.