Package com.clarkparsia.pellet.rules.model

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


    kb.addType( a, A );
   
    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() );
   
View Full Code Here


    ruleTranslator = new RulesToReteTranslator(kb.getABox());
  }

  @Test
  public void testClassAtom() {
    ClassAtom atom = new ClassAtom(a, vx);
    TermTuple triple = new TermTuple(DependencySet.INDEPENDENT, Compiler.TYPE, vrx, cra);
    assertEquals(triple, ruleTranslator.translateAtom(atom, DependencySet.INDEPENDENT));
  }
View Full Code Here

          varCount = processClass( newVar, filler, atoms, varCount );
        }
      }
    }
    else if( !c.equals( ATermUtils.TOP ) ) {
      atoms.add( new ClassAtom( c, var ) );
    }
   
    return varCount;
  }
View Full Code Here

      varId++;
    }

    // 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

    Set<RuleAtom> head = new LinkedHashSet<RuleAtom>();
    Set<RuleAtom> body = new LinkedHashSet<RuleAtom>();

    for( RuleAtom atom : rule.getHead() ) {
      if( atom instanceof ClassAtom ) {
        ClassAtom ca = (ClassAtom) atom;
        AtomIObject arg = ca.getArgument();
        ATermAppl c = ca.getPredicate();
        ATermAppl normC = ATermUtils.normalize( c );
        if( c != normC )
          atom = new ClassAtom( normC, arg );
      }
      head.add( atom );
    }

    Map<AtomIObject, Set<ATermAppl>> types = new HashMap<AtomIObject, Set<ATermAppl>>();

    for( RuleAtom atom : rule.getBody() ) {
      if( atom instanceof IndividualPropertyAtom ) {
        IndividualPropertyAtom propAtom = (IndividualPropertyAtom) atom;
        ATermAppl prop = propAtom.getPredicate();

        AtomIObject subj = propAtom.getArgument1();
        if( subj instanceof AtomIVariable ) {
          Set<ATermAppl> domains = getRole( prop ).getDomains();
          if( domains != null )
            MultiMapUtils.addAll( types, subj, domains );
        }

        AtomIObject obj = propAtom.getArgument2();
        if( obj instanceof AtomIVariable ) {
          Set<ATermAppl> ranges = getRole( prop ).getRanges();
          if( ranges != null )
            MultiMapUtils.addAll( types, obj, ranges );
        }
      }
    }

    for( RuleAtom atom : rule.getBody() ) {
      if( atom instanceof ClassAtom ) {
        ClassAtom ca = (ClassAtom) atom;
        AtomIObject arg = ca.getArgument();
        ATermAppl c = ca.getPredicate();
        ATermAppl normC = ATermUtils.normalize( c );
        if( MultiMapUtils.contains( types, arg, normC ) )
          continue;
        else if( c != normC )
          atom = new ClassAtom( normC, ca.getArgument() );
      }
      body.add( atom );
    }

    return new Rule( rule.getName(), head, body );
View Full Code Here

    kb.addType( a, A );
   
    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() );
   
View Full Code Here

    kb.addClass( c );
    kb.addClass( d );
    kb.addIndividual( i );
    kb.addType( i, c );

    kb.addRule( new Rule( Arrays.asList( new RuleAtom[] { new ClassAtom( d, new AtomIConstant(
        i ) ) } ), Arrays
        .asList( new RuleAtom[] { new ClassAtom( c, new AtomIConstant( i ) ) } ) ) );

    kb.realize();
    assertTrue( kb.getTypes( i ).contains( Collections.singleton( d ) ) );

  }
View Full Code Here

    AtomIVariable x = new AtomIVariable( "x" ), y = new AtomIVariable( "y" ), z = new AtomIVariable(
        "z" );

    kb.addRule( new Rule( Arrays.asList( new RuleAtom[] { new IndividualPropertyAtom( hasUncle,
        y, z ) } ), Arrays.asList( new RuleAtom[] {
        new IndividualPropertyAtom( hasParent, y, x ), new ClassAtom( male, z ),
        new IndividualPropertyAtom( hasSibling, x, z ), } ) ) );

    assertIteratorValues( kb.getObjectPropertyValues( hasUncle, c11 ).iterator(),
        new Object[] { p2a, } );
  }
View Full Code Here

    kb.addPropertyValue( p, x, b );
    kb.addPropertyValue( p, x, c );

    {
      AtomIVariable v = new AtomIVariable( "v" );
      RuleAtom body = new ClassAtom( some( p, or( and( A, B ), or(
          and( A, C ), and( B, C ) ) ) ), v );
      RuleAtom head = new IndividualPropertyAtom( q, v, new AtomIConstant( y ) );
      Rule rule = new Rule( Collections.singleton( head ), Collections.singleton( body ) );
      kb.addRule( rule );
    }

    {
      AtomIVariable v = new AtomIVariable( "v" );
      RuleAtom body = new ClassAtom( G, v );
      RuleAtom head = new IndividualPropertyAtom( p, v, new AtomIConstant( y ) );
      Rule rule = new Rule( Collections.singleton( head ), Collections.singleton( body ) );
      kb.addRule( rule );
    }
View Full Code Here

    kb.addDifferent( b, c );

    {
      AtomIVariable x = new AtomIVariable( "x" );
      List<RuleAtom> body = new ArrayList<RuleAtom>();
      body.add( new ClassAtom( C, x ) );
      List<RuleAtom> head = new ArrayList<RuleAtom>();
      head.add( new ClassAtom( C, x ) );
      Rule rule = new Rule( head, body );
      kb.addRule( rule );
    }

    assertTrue( kb.isConsistent() );
View Full Code Here

TOP

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

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.