Package org.mindswap.pellet

Examples of org.mindswap.pellet.KnowledgeBase


  }

  @Test
  public void testSimpleABoxRemove() {
    KnowledgeBase kb = new KnowledgeBase();

    ATermAppl a = term( "a" );
    ATermAppl C = term( "C" );
    ATermAppl D = term( "D" );

    kb.addClass( C );
    kb.addClass( D );

    kb.addIndividual( a );
    kb.addType( a, C );
    kb.addType( a, D );

    kb.removeType( a, D );

    assertTrue( kb.isConsistent() );
    assertTrue( kb.isType( a, C ) );
    assertFalse( kb.isType( a, D ) );
  }
View Full Code Here


    assertFalse( kb.isType( a, D ) );
  }

  @Test
  public void testABoxRemovalWithAllValues() {
    KnowledgeBase kb = new KnowledgeBase();

    ATermAppl a = term( "a" );
    ATermAppl b = term( "b" );

    ATermAppl C = term( "C" );

    ATermAppl p = term( "p" );

    kb.addClass( C );

    kb.addObjectProperty( p );

    kb.addIndividual( a );
    kb.addIndividual( b );

    kb.addType( a, all( p, C ) );
    kb.addType( b, C );

    kb.addPropertyValue( p, a, b );

    kb.removeType( b, C );

    kb.removePropertyValue( p, a, b );

    assertTrue( kb.isConsistent() );
    assertFalse( kb.isType( b, C ) );
    assertFalse( kb.hasPropertyValue( a, p, b ) );
  }
View Full Code Here

      ATermAppl A = ATermUtils.makeTermAppl( "A" );
      ATermAppl B = ATermUtils.makeTermAppl( "B" );
      ATermAppl C = ATermUtils.makeTermAppl( "C" );
      ATermAppl x = ATermUtils.makeTermAppl( "x" );

      KnowledgeBase kb = new KnowledgeBase();

      kb.addClass( A );
      kb.addClass( B );
      kb.addClass( C );
      kb.addIndividual( x );

      kb.addSubClass( C, A );

      kb.addType( x, C );
      kb.addType( x, B );

      Set<Set<ATermAppl>> expectedTypes = new HashSet<Set<ATermAppl>>();
      expectedTypes.add( Collections.singleton( ATermUtils.TOP ) );
      expectedTypes.add( Collections.singleton( A ) );
      expectedTypes.add( Collections.singleton( B ) );
      expectedTypes.add( Collections.singleton( C ) );

      assertTrue( kb.isConsistent() );

      Set<Set<ATermAppl>> actualTypes = kb.getTypes( x );
      assertEquals( expectedTypes, actualTypes );

      kb.addDisjointClass( A, B );
      assertFalse( kb.isConsistent() );

      assertTrue( kb.removeAxiom( ATermUtils.makeDisjoint( A, B ) ) );
      assertTrue( kb.isConsistent() );

      actualTypes = kb.getTypes( x );
      assertEquals( expectedTypes, actualTypes );

    } finally {
      PelletOptions.setOptions( savedOptions );
    }
View Full Code Here

    try {
      ATermAppl A = ATermUtils.makeTermAppl( "A" );
      ATermAppl B = ATermUtils.makeTermAppl( "B" );
      ATermAppl p = ATermUtils.makeTermAppl( "p" );

      KnowledgeBase kb = new KnowledgeBase();

      kb.addClass( A );
      kb.addClass( B );
      kb.addObjectProperty( p );

      ATermAppl or1 = or( A, some( p, A ) );
      ATermAppl or2 = or( B, some( p, B ) );

      ATermList list = ATermUtils.toSet( new ATerm[] { or1, or2 }, 2 );
      kb.addDisjointClasses( list );

      assertTrue( kb.isConsistent() );

      ATermAppl disjoint = ATermUtils.makeDisjoints( list );
      assertFalse( kb.removeAxiom( disjoint ) );
    } finally {
      PelletOptions.setOptions( savedOptions );
    }
  }
View Full Code Here

    try {
      ATermAppl A = ATermUtils.makeTermAppl( "A" );
      ATermAppl B = ATermUtils.makeTermAppl( "B" );
      ATermAppl p = ATermUtils.makeTermAppl( "p" );

      KnowledgeBase kb = new KnowledgeBase();

      kb.addClass( A );
      kb.addClass( B );
      kb.addObjectProperty( p );

      ATermAppl or1 = or( A, some( p, A ) );
      ATermAppl or2 = or( B, some( p, B ) );

      kb.addDisjointClass( or1, or2 );

      assertTrue( kb.isConsistent() );

      ATermAppl disjoint = ATermUtils.makeDisjoint( or1, or2 );
      assertFalse( kb.removeAxiom( disjoint ) );
    } finally {
      PelletOptions.setOptions( savedOptions );
    }
  }
View Full Code Here

    try {
      ATermAppl A = ATermUtils.makeTermAppl( "A" );
      ATermAppl p = ATermUtils.makeTermAppl( "p" );

      KnowledgeBase kb = new KnowledgeBase();

      kb.addClass( A );
      kb.addObjectProperty( p );

      kb.addSubClass( TOP, all( p, A ) );

      Role r = kb.getRole( p );

      assertTrue( kb.isConsistent() );
      assertTrue( r.getRanges().contains( A ) );

      assertFalse( kb.removeAxiom( ATermUtils.makeSub( TOP, all( p, A ) ) ) );
    } finally {
      PelletOptions.setOptions( savedOptions );
    }
  }
View Full Code Here

  @Test
  public void testAssertedSameAs() {
    // This test case is to test the processing of sameAs processing
    // where there are redundancies in the assertions (see ticket 138)

    KnowledgeBase kb = new KnowledgeBase();

    ATermAppl a = term( "a" );
    ATermAppl b = term( "b" );
    ATermAppl c = term( "c" );
    ATermAppl d = term( "d" );
    ATermAppl e = term( "e" );
    ATermAppl f = term( "f" );

    kb.addIndividual( a );
    kb.addIndividual( b );
    kb.addIndividual( c );
    kb.addIndividual( d );
    kb.addIndividual( e );
    kb.addIndividual( f );

    kb.addSame( a, b );
    kb.addSame( b, c );
    kb.addSame( c, d );
    kb.addSame( a, d );
    kb.addSame( b, d );
    kb.addSame( e, f );
    kb.addDifferent( e, f );

    assertFalse( kb.isConsistent() );
  }
View Full Code Here

    String dataName = dataset[0];

    Map<String, Query> queries = readQueries( queryset );

    KnowledgeBase kb = loadData( dataset );

    double parseTime = timers.getTimerTotal( "parse" ) / 1000.0;
    double consTime = timers.getTimerTotal( "consistency" ) / 1000.0;
   
    double classifyTime = 0;
    double realizeTime = 0;
    double sizeEstimateTime = 0;
   
    if( isSizeEstimateAll() ) {
      t = timers.startTimer( "sizeEstimateAll" );
      kb.getSizeEstimate().computeAll();
      t.stop();
     
    }

    System.out.println( "Parsing/Loading  : " + parseTime );
View Full Code Here

    System.out.println();
    System.out.println( "Triples        : " + model.getBaseModel().size() );
       
    t.stop();

    KnowledgeBase kb = loader.getKB();

    t = timers.startTimer( "load" );
    model.prepare();
    t.stop();
   
    ProfileUtils.printCounts( kb );

    t = timers.startTimer( "consistency" );
    kb.isConsistent();
    t.stop();
   
    ProfileUtils.printCounts( kb.getABox() );

    if( classify ) {
      t = timers.startTimer( "classify" );

      kb.classify();

      t.stop();
    }

    if( realize ) {
      t = timers.startTimer( "realize" );

      kb.realize();

      t.stop();
    }

    return kb;
View Full Code Here

      ? new JenaLoader()
      : new OWLAPILoader();
   
    loader.setIgnoreImports(!imports);
   
    KnowledgeBase kb = loader.getKB();

    List<Result<Task>> results = new ArrayList<Result<Task>>();

    for( int i = 0; i <= task.ordinal(); i++ ) {
      Task task = Task.values()[i];

      long start = System.currentTimeMillis();

      switch ( task ) {
      case Parse:
        loader.parse( FileUtils.getFileURIsFromRegex( files ).toArray( new String[0] ) );
        break;

      case Load:
        loader.load();
        ProfileUtils.printCounts( kb );
        break;

      case Consistency:
        kb.isConsistent();
        ProfileUtils.printCounts( kb.getABox() );
        break;

      case Classify:
        kb.classify();
        break;

      case Realize:
        kb.realize();
        break;

      default:
        throw new AssertionError( "This task does not exist: " + task );
      }

      double time = (System.currentTimeMillis() - start) / 1000.0;
      double mem = task.requiresInstances() && kb.getABox().isEmpty()
      ? results.get( results.size() - 1 ).getAvgMemory()
          : printProfile( kb, loader, "After " + task );
      results.add( new Result<Task>( task, mem, time ) );
    }
    kb.timers.print();
View Full Code Here

TOP

Related Classes of org.mindswap.pellet.KnowledgeBase

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.