Package com.clarkparsia.pellet.rules.model

Examples of com.clarkparsia.pellet.rules.model.Rule


   
    AtomIVariable x = new AtomIVariable( "x" )
    List<RuleAtom> body = Arrays.<RuleAtom>asList( new IndividualPropertyAtom( p, x, x ) );
    List<RuleAtom> head = Arrays.<RuleAtom>asList( new ClassAtom( A, x ) );
 
    kb.addRule( new Rule( head, body ) );
 
    assertTrue( kb.isConsistent() );
   
    assertTrue( kb.isType( a, A ) );
    assertFalse( kb.isType( b, A ) );
View Full Code Here


   
    AtomIVariable x = new AtomIVariable( "x" )
    List<RuleAtom> body = Arrays.<RuleAtom>asList( new IndividualPropertyAtom( p, x, new AtomIConstant( c ) ) );
    List<RuleAtom> head = Arrays.<RuleAtom>asList( new ClassAtom( A, x ) );
 
    kb.addRule( new Rule( head, body ) );
 
    assertTrue( kb.isConsistent() );
   
    assertFalse( kb.isType( a, A ) );
    assertTrue( kb.isType( b, A ) );
View Full Code Here

   */
  public Pair<Rule, VariableBinding> translateFact(Fact fact) {
    Pair<Rule, VariableBinding> partialApplication = null;
    if( (fact.getElements().size() >= VARSTARTPOS) && (fact.getElements().get( 0 ).equals( VARBINDING )) ) {
      Pair<Rule, List<AtomVariable>> ruleVarPair = ruleMap.get( fact.getElements().get( RULEPOS ) );
      Rule rule = ruleVarPair.first;
      List<AtomVariable> vars = ruleVarPair.second;
      List<ATermAppl> constants = fact.getElements().subList( VARSTARTPOS, fact.getElements().size() );

      if( vars.size() != constants.size() )
        throw new InternalReasonerException( "Variable list doesn't match constants!" );
View Full Code Here

    int total = 0;

    for( Fact ruleBinding : partialBindings.keySet() ) {
      Pair<Rule, VariableBinding> pair = continuousTransformer.translateFact( ruleBinding );
      Rule rule = pair.first;
      VariableBinding initial = pair.second;

      for( VariableBinding binding : bindingStrategy.createGenerator( rule, initial ) ) {

        Pair<Rule, VariableBinding> ruleKey = new Pair<Rule, VariableBinding>( rule,
View Full Code Here

    merging = false;
//    t = timers.startTimer( "rule-buildReteRules" );
    interpreter = new Interpreter( abox );
    for( Entry<Rule,Rule> e : abox.getKB().getNormalizedRules().entrySet() ) {
      Rule rule = e.getKey();
      Rule normalizedRule = e.getValue();
     
      if( normalizedRule == null )
        continue;
     
      com.clarkparsia.pellet.rules.rete.Rule reteRule;
View Full Code Here

    AtomIVariable x = new AtomIVariable( "x" )
    AtomIVariable y = new AtomIVariable( "y" )
    List<RuleAtom> body = Arrays.<RuleAtom>asList( new IndividualPropertyAtom( p, x, y ) );
    List<RuleAtom> head = Arrays.<RuleAtom>asList( new ClassAtom( B, x ) );
 
    kb.addRule( new Rule( head, body ) );
 
    assertTrue( kb.isConsistent() );
   
    kb.addPropertyValue( p, a, a );
   
View Full Code Here

    IndividualPropertyAtom bodyAtom = new IndividualPropertyAtom(pi, vx, ca);
    TermTuple bodyTriple = new TermTuple(DependencySet.INDEPENDENT, pi, vrx, cra);
    SameIndividualAtom headAtom = new SameIndividualAtom(vx, ca);
    TermTuple headTriple = new TermTuple(DependencySet.INDEPENDENT, Compiler.SAME_AS, vrx, cra);

    Rule rule = new Rule(Collections.singletonList((RuleAtom) headAtom), Collections
                    .singletonList((RuleAtom) bodyAtom));
    com.clarkparsia.pellet.rules.rete.Rule reteRule = new com.clarkparsia.pellet.rules.rete.Rule(Collections
                    .singletonList(bodyTriple), Collections.singletonList(headTriple));

    assertEquals(reteRule, ruleTranslator.translateRule(rule));
View Full Code Here

    }
   
    List<RuleAtom> headAtoms  = new ArrayList<RuleAtom>();
    processClass( var, ATermUtils.negate( head ), headAtoms, 1 );
   
    Rule rule = new Rule(headAtoms, bodyAtoms, explanation);
    kb.addRule( rule );
   

    if( log.isLoggable( Level.FINE ) )
      log.fine( "Absorbed rule: " + rule );
View Full Code Here

    // Then add the class atoms for the two subject variables
    body.add( new ClassAtom( c, x ) );
    body.add( new ClassAtom( c, y ) );
   
    addRule( new Rule( head, body ) );
  }
View Full Code Here

    // prepare the KB
    prepare();   
   
    for( Entry<Rule, Rule> normalizedRule : rules.entrySet() ) {
      if( normalizedRule.getValue() == null ) {
        Rule rule = normalizedRule.getKey();
        String msg = UsableRuleFilter.explainNotUsable( rule );       
        log.warning( "Ignoring rule " + rule + ": " + msg );
      }
    }
View Full Code Here

TOP

Related Classes of com.clarkparsia.pellet.rules.model.Rule

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.