Package com.clarkparsia.pellet.rules

Examples of com.clarkparsia.pellet.rules.VariableBinding


    kb.addIndividual(mary);
    kb.addIndividual(robert);
    kb.addIndividual(victor);

    BindingHelper genHelper = new ObjectVariableBindingHelper(kb.getABox(), x);
    BindingGenerator gen = new BindingGeneratorImpl(kb.getABox(), new VariableBinding(kb.getABox()), Collections
                    .singletonList(genHelper));

    assertIteratorValues(new BindingToMapIterator(gen.iterator()), new Object[] {
                    Collections.singletonMap(x, mary), Collections.singletonMap(x, robert),
                    Collections.singletonMap(x, victor), });
View Full Code Here


      return iter.hasNext();
    }

    public Map<AtomVariable, ATermAppl> next() {
      Map<AtomVariable, ATermAppl> result = new HashMap<AtomVariable, ATermAppl>();
      VariableBinding binding = iter.next();
      for (Map.Entry<? extends AtomVariable, ? extends Node> entry : binding.entrySet()) {
        result.put(entry.getKey(), entry.getValue().getTerm());
      }
      return result;
    }
View Full Code Here

    Collection<AtomVariable> xSingleton = Collections.singleton( (AtomVariable) x );
   
    BuiltInAtom oneVarAtom = new BuiltInAtom( Namespaces.SWRLB + "tokenize", x, data, semicolan );
    BindingHelper sharedVarHelper = StringOperators.tokenize.createHelper( oneVarAtom );
    assertTrue( sharedVarHelper.getBindableVars( emptyCollection ).equals( xSingleton ) );
    VariableBinding emptyBinding = new VariableBinding( kb.getABox() );
    sharedVarHelper.rebind( emptyBinding );
   
    VariableBinding fillBinding = new VariableBinding( kb.getABox() );
    List<String> expected = Arrays.asList( new String[] { "hi", "bye", "foo", "bar" } );
    List<String> tokens = new ArrayList<String>();
    while ( sharedVarHelper.selectNextBinding() ) {
      sharedVarHelper.setCurrentBinding( fillBinding );
      String token = ATermUtils.getLiteralValue( fillBinding.get( x ).getTerm() );
      tokens.add( token );
    }
    assertEquals("String tokenizer returned unexpected sequence of tokens", expected, tokens );
  }
View Full Code Here

    Collection<AtomVariable> xSingleton = Collections.singleton( (AtomVariable) x );
   
    BuiltInAtom oneVarAtom = new BuiltInAtom( Namespaces.SWRLB + "tokenize", x, data, comma );
    BindingHelper sharedVarHelper = StringOperators.tokenize.createHelper( oneVarAtom );
    assertTrue( sharedVarHelper.getBindableVars( emptyCollection ).equals( xSingleton ) );
    VariableBinding emptyBinding = new VariableBinding( kb.getABox() );
    sharedVarHelper.rebind( emptyBinding );
   
    VariableBinding fillBinding = new VariableBinding( kb.getABox() );
    List<String> expected = Collections.singletonList( ATermUtils.getLiteralValue( data.getValue() ) );
    List<String> tokens = new ArrayList<String>();
    while ( sharedVarHelper.selectNextBinding() ) {
      sharedVarHelper.setCurrentBinding( fillBinding );
      String token = ATermUtils.getLiteralValue( fillBinding.get( x ).getTerm() );
      tokens.add( token );
    }
    assertEquals("String tokenizer returned unexpected sequence of tokens", expected, tokens );
  }
View Full Code Here

   
    BuiltInAtom sharedVarAtom = new BuiltInAtom( Namespaces.SWRLB + "tokenize", x, x, comma );
    BindingHelper sharedVarHelper = StringOperators.tokenize.createHelper( sharedVarAtom );
    assertTrue( sharedVarHelper.getBindableVars( emptyCollection ).isEmpty() );
    assertTrue( sharedVarHelper.getBindableVars( xSingleton ).isEmpty() );
    VariableBinding xdataBinding = new VariableBinding( kb.getABox() );
    xdataBinding.set( x, data.getValue() );
    sharedVarHelper.rebind( xdataBinding );
    assertTrue( sharedVarHelper.selectNextBinding() );
    assertFalse( sharedVarHelper.selectNextBinding() );
 
  }
View Full Code Here

   
    BuiltInAtom sharedVarAtom = new BuiltInAtom( Namespaces.SWRLB + "tokenize", x, x, semicolan );
    BindingHelper sharedVarHelper = StringOperators.tokenize.createHelper( sharedVarAtom );
    assertTrue( sharedVarHelper.getBindableVars( emptyCollection ).isEmpty() );
    assertTrue( sharedVarHelper.getBindableVars( xSingleton ).isEmpty() );
    VariableBinding xdataBinding = new VariableBinding( kb.getABox() );
    xdataBinding.set( x, data.getValue() );
    sharedVarHelper.rebind( xdataBinding );
    assertFalse( sharedVarHelper.selectNextBinding() );
 
  }
View Full Code Here

TOP

Related Classes of com.clarkparsia.pellet.rules.VariableBinding

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.