Package com.clarkparsia.pellet.rules.model

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


    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 )
View Full Code Here


    OWLDescription c = atom.getPredicate();

    SWRLAtomIObject v = atom.getArgument();
    v.accept( this );

    AtomIObject subj = swrlIObject;

    c.accept( this );
    swrlAtom = new ClassAtom( term, subj );
  }
View Full Code Here

      swrlAtom = null;
      return;
    }

    atom.getFirstArgument().accept( this );
    AtomIObject subj = swrlIObject;

    atom.getSecondArgument().accept( this );
    AtomIObject obj = swrlIObject;

    atom.getPredicate().accept( this );
    swrlAtom = new IndividualPropertyAtom( term, subj, obj );

  }
View Full Code Here

      swrlAtom = null;
      return;
    }

    atom.getFirstArgument().accept( this );
    AtomIObject subj = swrlIObject;

    atom.getSecondArgument().accept( this );
    AtomDObject obj = swrlDObject;

    atom.getPredicate().accept( this );
View Full Code Here

    swrlAtom = new DatavaluedPropertyAtom( term, subj, obj );
  }

  public void visit(SWRLSameAsAtom atom) {
    atom.getFirstArgument().accept( this );
    AtomIObject subj = swrlIObject;

    atom.getSecondArgument().accept( this );
    AtomIObject obj = swrlIObject;

    swrlAtom = new SameIndividualAtom( subj, obj );
  }
View Full Code Here

    swrlAtom = new SameIndividualAtom( subj, obj );
  }

  public void visit(SWRLDifferentFromAtom atom) {
    atom.getFirstArgument().accept( this );
    AtomIObject subj = swrlIObject;

    atom.getSecondArgument().accept( this );
    AtomIObject obj = swrlIObject;

    swrlAtom = new DifferentIndividualsAtom( subj, obj );
  }
View Full Code Here

      Node atomNode = getObject( atomList, RDF.first.asNode() );

      RuleAtom atom = null;
      if( hasObject( atomNode, RDF.type.asNode(), SWRL.ClassAtom.asNode() ) ) {
        ATermAppl description = null;
        AtomIObject argument = null;
        atomType = "ClassAtom";

        if( (obj = getObject( atomNode, SWRL.classPredicate.asNode() )) != null ) {
                  description = node2term( obj );
                }

        if( (obj = getObject( atomNode, SWRL.argument1.asNode() )) != null ) {
                  argument = createRuleIObject( obj );
                }

        if( description == null ) {
                  addUnsupportedFeature( "Error on " + SWRL.classPredicate );
                }
                else if( argument == null ) {
                  addUnsupportedFeature( "Error on" + SWRL.argument1 );
                }
                else {
                  atom = new ClassAtom( description, argument );
                }
      }
      else if( hasObject( atomNode, RDF.type.asNode(), SWRL.IndividualPropertyAtom.asNode() ) ) {
        ATermAppl pred = null;
        AtomIObject argument1 = null;
        AtomIObject argument2 = null;
        atomType = "IndividualPropertyAtom";

        if( (obj = getObject( atomNode, SWRL.propertyPredicate.asNode() )) != null ) {
                  pred = node2term( obj );
                }

        if( (obj = getObject( atomNode, SWRL.argument1.asNode() )) != null ) {
                  argument1 = createRuleIObject( obj );
                }

        if( (obj = getObject( atomNode, SWRL.argument2.asNode() )) != null ) {
                  argument2 = createRuleIObject( obj );
                }

        if( pred == null || !defineObjectProperty( pred ) ) {
                  addUnsupportedFeature( "Cannot define datatype property " + pred );
                }
                else if( argument1 == null ) {
                  addUnsupportedFeature( "Term not found: " + SWRL.argument1 );
                }
                else if( argument2 == null ) {
                  addUnsupportedFeature( "Term not found " + SWRL.argument2 );
                }
                else {
                  atom = new IndividualPropertyAtom( pred, argument1, argument2 );
                }
      }
      else if( hasObject( atomNode, RDF.type.asNode(), SWRL.DifferentIndividualsAtom.asNode() ) ) {
        AtomIObject argument1 = null;
        AtomIObject argument2 = null;
        atomType = "DifferentIndividualsAtom";

        if( (obj = getObject( atomNode, SWRL.argument1.asNode() )) != null ) {
                  argument1 = createRuleIObject( obj );
                }

        if( (obj = getObject( atomNode, SWRL.argument2.asNode() )) != null ) {
                  argument2 = createRuleIObject( obj );
                }

        if( argument1 == null ) {
                  addUnsupportedFeature( "Term not found " + SWRL.argument1 );
                }
                else if( argument2 == null ) {
                  addUnsupportedFeature( "Term not found " + SWRL.argument2 );
                }
                else {
                  atom = new DifferentIndividualsAtom( argument1, argument2 );
                }
      }
      else if( hasObject( atomNode, RDF.type.asNode(), SWRL.SameIndividualAtom.asNode() ) ) {
        AtomIObject argument1 = null;
        AtomIObject argument2 = null;
        atomType = "SameIndividualAtom";

        if( (obj = getObject( atomNode, SWRL.argument1.asNode() )) != null ) {
                  argument1 = createRuleIObject( obj );
                }

        if( (obj = getObject( atomNode, SWRL.argument2.asNode() )) != null ) {
                  argument2 = createRuleIObject( obj );
                }

        if( argument1 == null ) {
                  addUnsupportedFeature( "Term not found " + SWRL.argument1 );
                }
                else if( argument2 == null ) {
                  addUnsupportedFeature( "Term not found " + SWRL.argument2 );
                }
                else {
                  atom = new SameIndividualAtom( argument1, argument2 );
                }
      }
      else if( hasObject( atomNode, RDF.type.asNode(), SWRL.DatavaluedPropertyAtom.asNode() ) ) {
        ATermAppl pred = null;
        AtomIObject argument1 = null;
        AtomDObject argument2 = null;
        atomType = "DatavaluedPropertyAtom";

        if( (obj = getObject( atomNode, SWRL.propertyPredicate.asNode() )) != null ) {
                  pred = node2term( obj );
View Full Code Here

  public void testRuleEquality() {
    ATermAppl r = term( "r" );
    ATermAppl i = term( "i" );
    ATermAppl j = term( "j" );

    AtomIObject x = new AtomIVariable( "x" );
    AtomIObject y = new AtomIVariable( "y" );

    KnowledgeBase kb = new KnowledgeBase();
    kb.addIndividual( i );
    kb.addIndividual( j );
    kb.addObjectProperty( r );
View Full Code Here

      return false;
    }
   
    set.remove( head );
   
    AtomIObject var = new AtomIVariable( "var");
    int varCount = 0;
    List<RuleAtom> bodyAtoms  = new ArrayList<RuleAtom>();
    for( ATermAppl term : set ) {
      varCount = processClass( var, term, bodyAtoms, varCount );
    }
View Full Code Here

          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

TOP

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

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.