Package com.clarkparsia.pellet.rules

Examples of com.clarkparsia.pellet.rules.BindingGenerator


    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);
          }
        }
      }
    }

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

TOP

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

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.