Package org.mindswap.pellet

Examples of org.mindswap.pellet.Individual


  @Override
  public void addType(Node node, ATermAppl c, DependencySet ds) {
    super.addType( node, c, ds );

    if( !merging && !abox.isClosed() && node.isRootNominal() && interpreter != null && node.isIndividual() ) {
      Individual ind = (Individual) node;
      interpreter.alphaNet.activateType(ind, c, ds);
    }
  }
View Full Code Here


  }
 
  public void activateAll() {
//    interpreter.addFact( EMPTY_FACT );
    for( Iterator<Individual> i = abox.getIndIterator(); i.hasNext(); ) {
      Individual ind = i.next();
      activateIndividual( ind );
    }
   
    return;
  }
View Full Code Here

 
  public void activateDifferents(Individual ind) {
    List<AlphaNode> alphas = map.get("DIFFERENT");
    if (alphas != null) {
      for (Node n : ind.getDifferents()) {
        Individual diff = (Individual) n;
        for (AlphaNode alpha : alphas) {
          ((AlphaDiffFromNode) alpha).activate(ind, diff, ind.getDifferenceDependency(diff));
        }
            } 
    }
View Full Code Here

      super( arg );
      this.c = c;
    }

    public DependencySet check(VariableBinding binding) {
      Individual ind = binding.get( getArg() );
      return ind.getDepends( c );
    }
View Full Code Here

    public TestSame(AtomIObject arg1, AtomIObject arg2) {
      super( arg1, arg2 );
    }

    public DependencySet check(VariableBinding binding) {
      Individual ind1 = binding.get( arg1 );
      Individual ind2 = binding.get( arg2 );
      if( ind1.isSame( ind2 ) ) {
        // we might be returning a super set of the actual dependency
        // set for the sameness since it is not straight-forward to come
        // up with the exact dependency set if there are other
        // individuals involved in this sameAs inference
        DependencySet ds1 = ind1.getMergeDependency( true );
        DependencySet ds2 = ind2.getMergeDependency( true );

        return ds1 == null
          ? ds2
          : ds2 == null
            ? ds1
View Full Code Here

  public Individual next() {
    if( !hasNext() ) {
      throw new NoSuchElementException();
    }
    Individual result = nextIndividual;
    nextIndividual = null;
    return result;
  }
View Full Code Here

  private SimpleIncrementalChangeTracker(SimpleIncrementalChangeTracker src, ABox target) {

    this.deletedEdges = new HashSet<Edge>( src.deletedEdges.size() );

    for( Edge se : src.deletedEdges ) {
      final Individual s = target.getIndividual( se.getFrom().getName() );
      if( s == null )
        throw new NullPointerException();
      final Node o = target.getNode( se.getTo().getName() );
      if( o == null )
        throw new NullPointerException();

      this.newEdges.add( new DefaultEdge( se.getRole(), s, o, se.getDepends() ) );
    }

    this.deletedTypes = new HashMap<Node, Set<ATermAppl>>( src.deletedTypes.size() );

    for( Map.Entry<Node, Set<ATermAppl>> e : src.deletedTypes.entrySet() ) {
      final Node n = target.getNode( e.getKey().getName() );
      if( n == null )
        throw new NullPointerException();
      this.deletedTypes.put( n, new HashSet<ATermAppl>( e.getValue() ) );
    }

    this.newEdges = new HashSet<Edge>( src.newEdges.size() );

    for( Edge se : src.newEdges ) {
      final Individual s = target.getIndividual( se.getFrom().getName() );
      if( s == null )
        throw new NullPointerException();
      final Node o = target.getNode( se.getTo().getName() );
      if( o == null )
        throw new NullPointerException();

      this.newEdges.add( new DefaultEdge( se.getRole(), s, o, se.getDepends() ) );
    }

    this.newIndividuals = new HashSet<Individual>( src.newIndividuals.size() );

    for( Individual si : src.newIndividuals ) {
      final Individual ti = target.getIndividual( si.getName() );
      if( ti == null )
        throw new NullPointerException();

      this.newIndividuals.add( ti );
    }

    this.unprunedNodes = new HashSet<Node>( src.unprunedNodes.size() );

    for( Node sn : src.unprunedNodes ) {
      final Node tn = target.getNode( sn.getName() );
      if( tn == null )
        throw new NullPointerException();

      this.unprunedNodes.add( tn );
    }

    this.updatedIndividuals = new HashSet<Individual>( src.updatedIndividuals.size() );

    for( Individual si : src.updatedIndividuals ) {
      final Individual ti = target.getIndividual( si.getName() );
      if( ti == null )
        throw new NullPointerException();

      this.updatedIndividuals.add( ti );
    }
View Full Code Here

    addType( ind, cls );
  }

  private void addType(ATermAppl ind, ATermAppl cls) {
    DependencySet nodeDS = ds;
    Individual node = abox.getIndividual( ind );
   
    if (node.isMerged()) {
      nodeDS = node.getMergeDependency(true);
      node = node.getSame();
   
   
    if( negated )
      cls = ATermUtils.negate( cls );
View Full Code Here

    strategy.addType( node, cls, nodeDS );
  }

  private void addEdge(ATermAppl p, ATermAppl s, ATermAppl o) {
    DependencySet edgeDS = ds;
    Individual node1 = abox.getIndividual( s );
   
    if (node1.isMerged()) {
      edgeDS = node1.getMergeDependency(true);
      node1 = node1.getSame();
    }   

    if( negated ) {
      ATermAppl cls = all( p, not( value( o ) ) );
      strategy.addType( node1, cls, ds );
View Full Code Here

      mergeAll();

     //Apply necessary initialization to any new individual added
     //Currently, this is a replication of the code
     for( Iterator<Individual> newIt = getNewIterator(); newIt.hasNext(); ) {
      Individual n = newIt.next();

      if (n.isMerged())
        continue;

      applyUniversalRestrictions(n);
     
      unfoldingRule.apply( n );
     
      selfRule.apply(n);       
    }
    
    //handle nodes affected by the update
    for (Iterator<Individual> it = getInitializeIterator(); it.hasNext();) {
   
      Individual n = it.next();

      nominalRule.apply(n);
     
      if (n.isMerged()){
        n = n.getSame();
      }

      allValuesRule.apply( n );
    }
   
    //process new edges
    for(Iterator<Edge> it = getNewEdgeIterator(); it.hasNext();){
      Edge edge = it.next();
     
      Individual subj = edge.getFrom();
      Node obj = edge.getTo();
      if(subj.isMerged())
        subj.getSame();
      if(subj.isPruned())
        continue;

      if(obj.isMerged())
        obj.getSame();
      if(obj.isPruned())
        continue;

      Role pred = edge.getRole();       
      DependencySet ds = edge.getDepends();

      applyDomainRange(subj, pred, obj, ds);
      if (subj.isPruned() || obj.isPruned()) {
        return;
      }
      applyFunctionality(subj, pred, obj);
      if (subj.isPruned() || obj.isPruned()) {
        return;
      }

      if (pred.isObjectRole()) {
        Individual o = (Individual) obj;
        checkReflexivitySymmetry(subj, pred, o, ds);
        checkReflexivitySymmetry(o, pred.getInverse(), subj, ds);
      }
     
      //if the KB has cardinality restrictions, then we need to apply the guessing rule
          if(abox.getKB().getExpressivity().hasCardinality()){
            //update the queue so the max rule will be fired
              updateQueueAddEdge(subj, pred, obj);
          }
    }
   
    
    //merge again if necessary
    if (!mergeList.isEmpty())
      mergeAll();
   
    //set appropriate branch
    abox.setBranch(abox.getBranches().size() + 1);

    // we will also need to add stuff to the queue in the event of a
    // deletion   
     
    //Handle removed edges
    Iterator<Edge> i = getRemovedEdgeIterator();
    while( i.hasNext() ){       
      Edge e = i.next();
      Individual subj = e.getFrom();
      Node obj = e.getTo();
     
      subj = subj.getSame();
     
      subj.applyNext[Node.SOME] = 0;
      subj.applyNext[Node.MIN] = 0;
      QueueElement qe = new QueueElement( subj );
      abox.getCompletionQueue().add( qe, NodeSelector.EXISTENTIAL );
      abox.getCompletionQueue().add( qe, NodeSelector.MIN_NUMBER );
     
     
      obj = obj.getSame();
      if(obj instanceof Individual){
        Individual objInd = (Individual)obj;
        objInd.applyNext[Node.SOME] = 0;
        objInd.applyNext[Node.MIN] = 0;
        qe = new QueueElement( objInd );
        abox.getCompletionQueue().add( qe, NodeSelector.EXISTENTIAL );
        abox.getCompletionQueue().add( qe, NodeSelector.MIN_NUMBER );
      }               
    }

   
   
   
    //Handle removed types
    Iterator<Map.Entry<Node,Set<ATermAppl>>> it = getRemovedTypeIterator();
    while( it.hasNext() ){
      Node node = it.next().getKey();
     
      if( node.isIndividual() ){
        Individual ind = (Individual)node;

        //readd the conjunctions
        readdConjunctions( ind );
       
        //it could be the case that the type can be added from unfolding, a forAll application on a self loop, or the disjunction rule
        ind.applyNext[Node.ATOM] = 0;
        ind.applyNext[Node.ALL] = 0;
        ind.applyNext[Node.OR] = 0;

        QueueElement qe = new QueueElement( ind );
        abox.getCompletionQueue().add( qe, NodeSelector.ATOM );
        abox.getCompletionQueue().add( qe, NodeSelector.DISJUNCTION );

        //fire the all rule as the is no explicit call to it
        allValuesRule.apply( ind );
       
        //get out edges and check domains, some values and min values
        for( int j = 0; j < ind.getOutEdges().size(); j++ ){
          Edge e = ind.getOutEdges().edgeAt( j );
                       
          if( e.getFrom().isPruned() || e.getTo().isPruned() )
            continue;
                       
              Role pred = e.getRole();
              Node obj = e.getTo();
              DependencySet ds = e.getDepends();
         
              for( ATermAppl domain : pred.getDomains() ) {             
                if( requiredAddType( ind, domain ) ) {
              if( !PelletOptions.USE_TRACING )
                addType( ind, domain, ds.union( DependencySet.EMPTY, abox.doExplanation() ) );
              else        
                addType( ind, domain, ds.union( pred.getExplainDomain( domain ), abox.doExplanation() ) );
                }
              }

              //it could be the case that this label prevented the firing of the all values, some, or min rules of the neighbor
          if( obj instanceof Individual ){
            Individual objInd = (Individual)obj;
            objInd.applyNext[Node.ALL] = 0;
            objInd.applyNext[Node.SOME] = 0;
            objInd.applyNext[Node.MIN] = 0;
            QueueElement qeObj = new QueueElement( objInd );
            abox.getCompletionQueue().add( qeObj, NodeSelector.EXISTENTIAL );
            abox.getCompletionQueue().add( qeObj, NodeSelector.MIN_NUMBER );
           
            //apply the all values rule
            allValuesRule.apply( ind );
          }
        }
      }
       
     
      //get out edges
      for( int j = 0; j < node.getInEdges().size(); j++ ){
        Edge e = node.getInEdges().edgeAt( j );
                     
        if( e.getFrom().isPruned() || e.getTo().isPruned() )
          continue;
       
        Individual subj = e.getFrom();
              Role pred = e.getRole();              
              DependencySet ds = e.getDepends();
       
            for( ATermAppl range : pred.getRanges() ) {
              if( requiredAddType( node, range ) ) {
            if( !PelletOptions.USE_TRACING )
              addType( node, range, ds.union( DependencySet.EMPTY, abox.doExplanation() ) );
            else        
              addType( node, range, ds.union( pred.getExplainRange( range ), abox.doExplanation() ) );
              }
            }

            //it could be the case that this label prevented the firing of the all values, some, or min rules of the neighbor
        subj.applyNext[Node.ALL] = 0;
        subj.applyNext[Node.SOME] = 0;
        subj.applyNext[Node.MIN] = 0;
        QueueElement qe = new QueueElement( subj );
        abox.getCompletionQueue().add( qe, NodeSelector.EXISTENTIAL );
        abox.getCompletionQueue().add( qe, NodeSelector.MIN_NUMBER );

        allValuesRule.apply( subj );
      }
    }
   
   
    //due to unmerging nodes, edges can actually be added
    i = getNewEdgeIterator();
    while( i.hasNext() ){       
      applyPropertyRestrictions( i.next() );       
    }
   
   
    //due to unmerging any node that was pruned could need rules applied to it. This is because these rules
    //would have been originally applied to the node that the pruned node was merged into. 
    for(Iterator<Node> nodeIt = getUnPrunedIterator(); nodeIt.hasNext(); ) {
      Node n = nodeIt.next();
     
      if( n.isIndividual() ) {
        Individual ind = (Individual) n;
       
        //reset type pointers
        for( int j = 0; j < Node.TYPES; j++ )
          ind.applyNext[j] = 0;
       
        //add to all queues
        abox.getCompletionQueue().add( new QueueElement( ind ) );
       
        allValuesRule.apply( ind );
       
        //get out edges
        for( int j = 0; j < ind.getOutEdges().size(); j++ ){
          Edge e = ind.getOutEdges().edgeAt( j );
                       
          if( !e.getFrom().isPruned() && !e.getTo().isPruned() )
            applyPropertyRestrictions( e );
         
          Node obj = e.getTo();
          if( obj instanceof Individual ){
            Individual objInd = (Individual)obj;
            objInd.applyNext[Node.ALL] = 0;
            allValuesRule.apply( objInd );
          }
        }
         
       
        //get out edges
        for( int j = 0; j < ind.getInEdges().size(); j++ ){
          Edge e = ind.getInEdges().edgeAt( j );
                       
          if( !e.getFrom().isPruned() && !e.getTo().isPruned() )
            applyPropertyRestrictions( e );
         
          Individual subj= e.getFrom();
          subj.applyNext[Node.ALL] = 0;
          allValuesRule.apply( subj );
        }
      }
    }
View Full Code Here

TOP

Related Classes of org.mindswap.pellet.Individual

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.