Examples of RuleAtom


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

  }

  public void testVariableUtils2() {
    ATermAppl p = term( "p" );
    AtomIVariable var1 = new AtomIVariable( "var1" ), var2 = new AtomIVariable( "var2" );
    RuleAtom atom = new IndividualPropertyAtom( p, var1, var2 );
    assertIteratorValues( VariableUtils.getVars( atom ).iterator(), new Object[] { var1, var2 } );
  }
View Full Code Here

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

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

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

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

     
      if( filler.getAFun().equals( ATermUtils.VALUEFUN ) ) {
        ATermAppl nominal = (ATermAppl) filler.getArgument( 0 );
        if( kb.isDatatypeProperty( p ) ) {
          AtomDConstant arg = new AtomDConstant( nominal );
          RuleAtom atom = new DatavaluedPropertyAtom( p, var, arg );
          atoms.add(atom);
        }
        else {
          AtomIConstant arg = new AtomIConstant( nominal );
          RuleAtom atom = new IndividualPropertyAtom( p, var, arg );
          atoms.add(atom);
        }
      }
      else {
        varCount++;
        if( kb.isDatatypeProperty( p ) ) {
          AtomDObject newVar = new AtomDVariable( "var" + varCount );
          RuleAtom atom = new DatavaluedPropertyAtom( p, var, newVar );
          atoms.add(atom);
          processDatatype( newVar, filler, atoms );
        }
        else{
          AtomIObject newVar = new AtomIVariable( "var" + varCount );
          RuleAtom atom = new IndividualPropertyAtom( p, var, newVar );
          atoms.add(atom);
          varCount = processClass( newVar, filler, atoms, varCount );
        }
      }
    }
View Full Code Here

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

  private RuleAtom pickNextAtom(List<RuleAtom> atoms, Set<AtomVariable> bound) {
    int index = 0;
    if (bound.isEmpty()) {
      for (int i = 0; i < atoms.size(); i++) {
        RuleAtom atom = atoms.get(i);   
        if (safetyChecker.isSafe(atom)) {
          return atoms.remove(i);
        }
      }
    }
    else {
      for (int i = 0; i < atoms.size(); i++) {
        RuleAtom atom = atoms.get(i);
        if (SetUtils.intersects(bound, atom.getAllArguments())) {
          index = i;
          if (safetyChecker.isSafe(atom)) {
            break;
          }
        }
View Full Code Here

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

    int lastSafe = -1;
    ReteNode lastSafeBeta = null;
   
    boolean canReuseBeta = false;
   
    RuleAtom atom = null;
    ReteNode node = null;
    while (!atoms.isEmpty()) {
      atom = pickNextAtom(atoms, bound);
     
      if (!safetyChecker.isSafe(atom)) {
        lastSafe = processed.size();
        lastSafeBeta = node;
      }
     
      AlphaNode alpha = alphaNet.addNode(atom);
      List<? extends AtomObject> args = atom.getAllArguments();
     
      List<FilterCondition> conditions = new ArrayList<FilterCondition>();
      if (!processed.isEmpty()) {
        for (int i = 0, n = args.size(); i < n; i++) {
          AtomObject arg = args.get(i);
View Full Code Here

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

    return (TokenNodeProvider) createNodeProvider(arg, processed, false);
  }
 
  private static NodeProvider createNodeProvider(AtomVariable arg, List<RuleAtom> processed, boolean lastWME) {
    for (int index = 0, n = processed.size(); index < n; index++) {
      RuleAtom sharedAtom = processed.get(index)
            int indexArg = sharedAtom.getAllArguments().indexOf(arg);
            if (indexArg != -1) {
              if (lastWME && index == n -1) {
                return new WMENodeProvider(indexArg);
              }
              else {
View Full Code Here

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

    AtomIVariable x = new AtomIVariable( "x" );
    AtomDVariable xDate = new AtomDVariable( "xDate" ), xYear = new AtomDVariable( "xYear" ), xMonth = new AtomDVariable(
        "xMonth" ), xDay = new AtomDVariable( "xDay" ), xTZ = new AtomDVariable( "xTZ" );

    RuleAtom dateBuiltIn = new BuiltInAtom( SWRLB + "date", xDate, xYear, xMonth, xDay );
    RuleAtom dateBuiltInTZ = new BuiltInAtom( SWRLB + "date", xDate, xYear, xMonth, xDay, xTZ );
    RuleAtom bDateAtom = new DatavaluedPropertyAtom( bDate, x, xDate );
    RuleAtom bYearAtom = new DatavaluedPropertyAtom( bYear, x, xYear );
    RuleAtom bMonthAtom = new DatavaluedPropertyAtom( bMonth, x, xMonth );
    RuleAtom bDayAtom = new DatavaluedPropertyAtom( bDay, x, xDay );
    RuleAtom bTZAtom = new DatavaluedPropertyAtom( bTZ, x, xTZ );

    Rule fromDate = new Rule( Arrays
        .asList( new RuleAtom[] { bYearAtom, bMonthAtom, bDayAtom } ), Arrays
        .asList( new RuleAtom[] { dateBuiltIn, bDateAtom } ) );
    kb.addRule( fromDate );
View Full Code Here

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

    kb.addPropertyValue( r, j, k );

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

    RuleAtom body1 = new IndividualPropertyAtom( r, x, y );
    RuleAtom body2 = new DatavaluedPropertyAtom( p, x, z ), head = new DatavaluedPropertyAtom(
        p, y, z );

    Rule rule = new Rule( Collections.singleton( head ), Arrays.asList( new RuleAtom[] {
        body1, body2 } ) );
    kb.addRule( rule );
View Full Code Here

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

    kb.addPropertyValue( p, i, d );

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

    RuleAtom body1 = new IndividualPropertyAtom( r, x, y );
    RuleAtom body2 = new DatavaluedPropertyAtom( p, x, z );
    RuleAtom head = new DatavaluedPropertyAtom( p, y, z );

    Rule rule = new Rule( Collections.singleton( head ), Arrays.asList( body1, body2 ) );
    kb.addRule( rule );

    kb.realize();
View Full Code Here

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

    kb.addPropertyValue( p, i, d );

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

    RuleAtom head = new DatavaluedPropertyAtom( p, x, z );
    RuleAtom body1 = new DatavaluedPropertyAtom( p, y, z );
    RuleAtom body2 = new IndividualPropertyAtom( r, x, y );

    Rule rule = new Rule( Collections.singleton( head ), Arrays.asList( body1, body2 ) );
    kb.addRule( rule );
   
    kb.ensureConsistency();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.