Package com.clarkparsia.pellet.rules

Examples of com.clarkparsia.pellet.rules.BindingHelper


  }

  @Test
  public void testCombinatorialBindingGeneration() {
    BindingHelper genHelper1 = new ObjectVariableBindingHelper(kb.getABox(), x);
    BindingHelper genHelper2 = new ObjectVariableBindingHelper(kb.getABox(), y);

    Individual[] individualsUsed = { kb.getABox().getIndividual(mary), kb.getABox().getIndividual(robert),
                    kb.getABox().getIndividual(victor), };

    List<BindingHelper> genSet = new ArrayList<BindingHelper>();
View Full Code Here


  @Test
  public void testDataRangeBindingHelper() {
    DatavaluedPropertyAtom pattern = new DatavaluedPropertyAtom(dp2, x, z);
    DataRangeAtom atom = new DataRangeAtom(ATermUtils.makeTermAppl(Namespaces.XSD + "integer"), z);

    BindingHelper patternHelper = new DatavaluePropertyBindingHelper(kb.getABox(), pattern);
    BindingHelper rangeHelper = new DataRangeBindingHelper(kb.getABox(), atom);
    BindingGenerator gen = new BindingGeneratorImpl(kb.getABox(), new VariableBinding(kb.getABox()), Arrays
                    .asList(new BindingHelper[] { patternHelper, rangeHelper, }));

    VariableBinding expectedBinding = new VariableBinding(kb.getABox());
    expectedBinding.set(x, kb.getABox().getIndividual(victor));
View Full Code Here

  @Test
  public void testDatavalueBindingGeneratorChained() {
    DatavaluedPropertyAtom pattern1 = new DatavaluedPropertyAtom(dp2, x, z);
    DatavaluedPropertyAtom pattern2 = new DatavaluedPropertyAtom(dp2, y, z);

    BindingHelper genHelper1 = new DatavaluePropertyBindingHelper(kb.getABox(), pattern1);
    BindingHelper genHelper2 = new DatavaluePropertyBindingHelper(kb.getABox(), pattern2);
    BindingGenerator gen = new BindingGeneratorImpl(kb.getABox(), new VariableBinding(kb.getABox()), Arrays
                    .asList(new BindingHelper[] { genHelper1, genHelper2 }));

    List<VariableBinding> expected = new LinkedList<VariableBinding>();
    VariableBinding binding;
View Full Code Here

  @Test
  public void testDatavalueBindingGeneratorChainedSubject() {
    DatavaluedPropertyAtom pattern1 = new DatavaluedPropertyAtom(dp2, x, new AtomDConstant(data2));
    DatavaluedPropertyAtom pattern2 = new DatavaluedPropertyAtom(dp2, y, new AtomDConstant(data2));

    BindingHelper genHelper1 = new DatavaluePropertyBindingHelper(kb.getABox(), pattern1);
    BindingHelper genHelper2 = new DatavaluePropertyBindingHelper(kb.getABox(), pattern2);
    BindingGenerator gen = new BindingGeneratorImpl(kb.getABox(), new VariableBinding(kb.getABox()), Arrays
                    .asList(new BindingHelper[] { genHelper1, genHelper2 }));

    List<VariableBinding> expected = new LinkedList<VariableBinding>();
    VariableBinding binding;
View Full Code Here

  @Test
  public void testDatavalueBindingGeneratorObjects() {
    DatavaluedPropertyAtom pattern = new DatavaluedPropertyAtom(dp2, new AtomIConstant(mary), z);

    BindingHelper genHelper = new DatavaluePropertyBindingHelper(kb.getABox(), pattern);
    BindingGenerator gen = new BindingGeneratorImpl(kb.getABox(), new VariableBinding(kb.getABox()), Collections
                    .singletonList(genHelper));
    assertIteratorValues(new BindingToMapIterator(gen.iterator()), new Object[] {
                    Collections.singletonMap(z, data1), Collections.singletonMap(z, data2), });
View Full Code Here

  @Test
  public void testDatavalueBindingGeneratorSubjects() {
    DatavaluedPropertyAtom pattern = new DatavaluedPropertyAtom(dp2, x, new AtomDConstant(data2));

    BindingHelper genHelper = new DatavaluePropertyBindingHelper(kb.getABox(), pattern);
    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), });
View Full Code Here

  public void testObjectVariableBindingGenerator() {
    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),
View Full Code Here

    AtomDConstant semicolan = new AtomDConstant( literal( ";" ) );
    Collection<AtomVariable> emptyCollection = Collections.emptySet();
    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

    AtomDConstant comma = new AtomDConstant( literal( "," ) );
    Collection<AtomVariable> emptyCollection = Collections.emptySet();
    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

    AtomDConstant comma = new AtomDConstant( literal( "," ) );
    Collection<AtomVariable> emptyCollection = Collections.emptySet();
    Collection<AtomVariable> xSingleton = Collections.singleton( (AtomVariable) x );
   
    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

TOP

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

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.