Package com.clarkparsia.pellet.rules

Examples of com.clarkparsia.pellet.rules.VariableBinding


      for ( int i = 0; i < arguments.length; i++ ) {
        arguments[i] = newBinding.get( atom.getAllArguments().get( i ) );
      }
     
      if ( function.apply( newBinding.getABox(), arguments ) ) {
        VariableBinding newPartial = new VariableBinding( newBinding.getABox() );
        for ( int i = 0; i < arguments.length; i++ ) {
          AtomDObject arg = atom.getAllArguments().get( i );
          Literal result = arguments[ i ];
          Literal current = newBinding.get( arg );
         
View Full Code Here


    }
   
    @Override
    public void activate(Token token) {
      resetDependencySet(token);
      VariableBinding binding = new VariableBinding(strategy.getABox());
      for (Entry<AtomVariable, NodeProvider> entry : args.entrySet()) {
        AtomObject arg = entry.getKey();
        Node node = getNode(args.get(arg), token);
        if (arg instanceof AtomIVariable) {
          binding.set((AtomIVariable) arg, (Individual) node);
        }
        else {
          binding.set((AtomDVariable) arg, (Literal) node);
        }
            }
      if (log.isLoggable(Level.FINE)) {
        log.fine("Produce binding " + rule + " -> " + binding);
        }
View Full Code Here

      for ( int i = 0; i < arguments.length; i++ ) {
        arguments[i] = newBinding.get( atom.getAllArguments().get( i ) );
      }
     
      if ( function.apply( newBinding.getABox(), arguments ) ) {
        VariableBinding newPartial = new VariableBinding( newBinding.getABox() );
        for ( int i = 0; i < arguments.length; i++ ) {
          AtomDObject arg = atom.getAllArguments().get( i );
          Literal result = arguments[ i ];
          Literal current = newBinding.get( arg );
         
View Full Code Here

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

    List<BindingHelper> genSet = new ArrayList<BindingHelper>();

    BindingGenerator emptyGen = new BindingGeneratorImpl(kb.getABox(), new VariableBinding(kb.getABox()), genSet);
    assertFalse(emptyGen.iterator().hasNext());

    genSet.add(genHelper1);
    genSet.add(genHelper2);

    BindingGenerator gen = new BindingGeneratorImpl(kb.getABox(), new VariableBinding(kb.getABox()), genSet);
    List<VariableBinding> expected = new LinkedList<VariableBinding>();
    for (Individual xNode : individualsUsed) {
      for (Individual yNode : individualsUsed) {
        VariableBinding bindings = new VariableBinding(kb.getABox());
        bindings.set(x, xNode);
        bindings.set(y, yNode);
        expected.add(bindings);
      }
    }
    assertIteratorValues(gen.iterator(), expected.iterator());
  }
View Full Code Here

    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));
    expectedBinding.set(z, kb.getABox().getLiteral(data4));
    List<VariableBinding> expected = new LinkedList<VariableBinding>();
    expected.add(expectedBinding);

    assertIteratorValues(gen.iterator(), expected.iterator());
View Full Code Here

    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;
    ATermAppl[] names = new ATermAppl[] { mary, robert, victor };
    ATermAppl[] values = new ATermAppl[] { data1, data2, data3, data4 };
    for (ATermAppl xName : names) {
      for (ATermAppl yName : names) {
        for (ATermAppl zValue : values) {
          Individual xNode = kb.getABox().getIndividual(xName);
          Individual yNode = kb.getABox().getIndividual(yName);
          Literal zNode = kb.getABox().addLiteral(zValue);

          if (kb.hasPropertyValue(xName, dp2, zValue) && kb.hasPropertyValue(yName, dp2, zValue)) {
            binding = new VariableBinding(kb.getABox());
            binding.set(x, xNode);
            binding.set(y, yNode);
            binding.set(z, zNode);
            expected.add(binding);
          }
        }
      }
    }
View Full Code Here

    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;
    ATermAppl[] names = new ATermAppl[] { mary, robert };
    for (ATermAppl xName : names) {
      for (ATermAppl yName : names) {
        Individual xNode = kb.getABox().getIndividual(xName);
        Individual yNode = kb.getABox().getIndividual(yName);

        binding = new VariableBinding(kb.getABox());
        binding.set(x, xNode);
        binding.set(y, yNode);
        expected.add(binding);
      }
    }

    assertIteratorValues(gen.iterator(), expected.iterator());
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

    kb.addObjectProperty(p);
    kb.addIndividual(mary);
    kb.addIndividual(robert);
    kb.addPropertyValue(p, mary, robert);

    VariableBinding binding = new VariableBinding(kb.getABox());
    binding.set(x, mary);
    binding.set(y, robert);

    RuleAtom atom = new IndividualPropertyAtom(p, x, y);
    TrivialSatisfactionHelpers tester = new TrivialSatisfactionHelpers(kb.getABox());
    assertTrue(tester.isAtomTrue(atom, binding) != null);
  }
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.