Examples of EdgeList


Examples of org.mindswap.pellet.EdgeList

     *
     * @return true if more merges are required for this maxCardinality
     */
    protected boolean applyMaxRule( Individual x, Role r, ATermAppl c, int k, DependencySet ds ) {

        EdgeList edges = x.getRNeighborEdges( r );
        // find all distinct R-neighbors of x
        Set<Node> neighbors = edges.getFilteredNeighbors( x, c );

        int n = neighbors.size();

        // if( log.isLoggable( Level.FINE ) )
        // log.fine( "Neighbors: " + n + " maxCardinality: " + k);

        // if restriction was maxCardinality 0 then having any R-neighbor
        // violates the restriction. no merge can fix this. compute the
        // dependency and return
        if( k == 0 && n > 0 ) {
            for( int e = 0; e < edges.size(); e++ ) {
                Edge edge = edges.edgeAt( e );
                Node neighbor = edge.getNeighbor( x );
                DependencySet typeDS = neighbor.getDepends( c );
                if( typeDS != null ) {
                  Role edgeRole = edge.getRole();
            DependencySet subDS = r.getExplainSubOrInv( edgeRole );
View Full Code Here

Examples of org.mindswap.pellet.EdgeList

            if (PelletOptions.USE_TRACING) {
              ds = ds.union( s.getExplainSuper(r.getName()), strategy.getABox().doExplanation() ).union( r.getExplainFunctional(), strategy.getABox().doExplanation() );
            }
           
            EdgeList edges = x.getRNeighborEdges( r );

            // if there is not more than one edge then func max rule won't be triggered
            if( edges.size() <= 1 )
                continue;

            // find all distinct R-neighbors of x
            Set<Node> neighbors = edges.getFilteredNeighbors( x, c );

            // if there is not more than one neighbor then func max rule won't be triggered
            if( neighbors.size() <= 1 )
                continue;

            Node head = null;

            int edgeIndex = 0;
            int edgeCount = edges.size();

            // find the head and its corresponding dependency information.
            // since head is not necessarily the first element in the
            // neighbor list we need to first find the un-pruned node
            for( ; edgeIndex < edgeCount; edgeIndex++ ) {
                Edge edge = edges.edgeAt( edgeIndex );
                head = edge.getNeighbor( x );

                if( head.isPruned() || !neighbors.contains( head ) )
                    continue;

                // this node is included in the merge list because the edge
                // exists and the node has the qualification in its types
                ds = ds.union( edge.getDepends(), strategy.getABox().doExplanation() );
                ds = ds.union( head.getDepends( c ), strategy.getABox().doExplanation() );
                ds = ds.union( r.getExplainSubOrInv( edge.getRole() ), strategy.getABox().doExplanation() );
                break;
            }

            // now iterate through the rest of the elements in the neighbors
            // and merge them to the head node. it is possible that we will
            // switch the head at some point because of merging rules such
            // that you always merge to a nominal of higher level
            for( edgeIndex++; edgeIndex < edgeCount; edgeIndex++ ) {
                Edge edge = edges.edgeAt( edgeIndex );
                Node next = edge.getNeighbor( x );

                if( next.isPruned() || !neighbors.contains( next ) )
                    continue;
View Full Code Here

Examples of org.mindswap.pellet.EdgeList

         
          entry.setValue( tDS );
        }
 
        // update edge depdencies
        EdgeList edges = node.getInEdges();
        for( Edge edge: edges ) {
          DependencySet tDS = edge.getDepends();
 
          // DependencySet.copy() does not create a new bitset object,
          // so we need to track which bitsets have been
View Full Code Here

Examples of org.mindswap.pellet.EdgeList

    Individual subj = kb.getABox().getIndividual( theEdge.getFrom().getName() );
    Node obj = kb.getABox().getNode( theEdge.getTo().getName() );
    Role role = kb.getRole( theEdge.getRole().getName() );
 
    // loop over all edges for the subject
    EdgeList edges = subj.getEdgesTo( obj, role );
    for( int i = 0; i < edges.size(); i++ ) {
      Edge edge = edges.edgeAt( i );
      if( edge.getRole().equals( role ) ) {
        // get dependency set for the edge
        DependencySet ds = edge.getDepends();
 
        // clean it
View Full Code Here

Examples of org.mindswap.pellet.EdgeList

        if ( s.isTop() && s.isObjectRole() ) {
          applyAllValuesTop( av, c, ds );
          return;
        }

        EdgeList edges = x.getRNeighborEdges( s );
        for( int e = 0; e < edges.size(); e++ ) {
            Edge edgeToY = edges.edgeAt( e );
            Node y = edgeToY.getNeighbor( x );
            DependencySet finalDS = ds.union( edgeToY.getDepends(), strategy.getABox().doExplanation() );
           
            if( roleChain.isEmpty() )
                applyAllValues( x, s, y, c, finalDS );
View Full Code Here

Examples of org.mindswap.pellet.EdgeList

    }

    protected boolean applyAllValuesPropertyChain( Individual x, ATermList chain, ATermAppl c, DependencySet ds ) {
         Role r = strategy.getABox().getRole( chain.getFirst() );
        
         EdgeList edges = x.getRNeighborEdges( r );
         if( !edges.isEmpty() ) {
             ATermAppl allRC = ATermUtils.makeAllValues( chain.getNext(), c );

             for( int e = 0; e < edges.size(); e++ ) {
                 Edge edgeToY = edges.edgeAt( e );
                 Node y = edgeToY.getNeighbor( x );
                 DependencySet finalDS = ds.union( edgeToY.getDepends(), strategy.getABox().doExplanation() );
                
                 applyAllValues( x, r, y, allRC, finalDS );
View Full Code Here

Examples of org.mindswap.pellet.EdgeList

  }

  public Iterator<WME> getMatches() {
    Individual subject = initNode();
    Node object = initObjectNode();
    EdgeList edges = subject.getEdgesTo(object, role);
    return toWMEs(edges, EdgeDirection.FORWARD);
  }
View Full Code Here

Examples of org.mindswap.pellet.EdgeList

        throw new InternalReasonerException( "Cannot retreive role!: " + p );
      }
    }

    public DependencySet check(Individual node1, Node node2) {
      EdgeList list = node1.getRNeighborEdges( r );
      for( int i = 0, n = list.size(); i < n; i++ ) {
        Edge edge = list.edgeAt( i );
        if( edge.getNeighbor( node1 ).equals( node2 ) ) {
          return edge.getDepends();
        }
      }
View Full Code Here

Examples of org.mindswap.pellet.EdgeList

      Node node = entry.getKey();
      Set<ATermAppl> types = entry.getValue();
     
      // find the edges which the all values rule needs to be
      // re-applied to
      EdgeList av = findAllValues( node, types );
     
      //apply the all values rules
      for(int i = 0; i < av.size(); i++){
        Edge e = av.edgeAt( i );           
        allValuesRule.applyAllValues( e.getFrom(), e.getRole(), e.getTo(), e.getDepends() );
      }
    }
   
    for( Iterator<Node> i = tracker.unprunedNodes(); i.hasNext(); ) {
View Full Code Here

Examples of org.mindswap.pellet.EdgeList

   * @param node
   * @param removedTypes
   * @return
   */
  protected EdgeList findAllValues( Node node, Set<ATermAppl> removedTypes){
    EdgeList edges = new EdgeList();
   
    //handle in edges
    for(int i = 0; i < node.getInEdges().size(); i++){
      Edge e = node.getInEdges().edgeAt( i );
     
      edges.addEdgeList( findAllValues( node, e.getFrom(), removedTypes, e ) );
    }
   
   
    if( node instanceof Individual ){
      Individual ind = (Individual)node;     
     
      //handle in edges
      for(int i = 0; i < ind.getOutEdges().size(); i++){
        Edge e = ind.getOutEdges().edgeAt( i );
        Node to = e.getTo();
       
        Role inv = e.getRole().getInverse();
       
        if(inv != null && to instanceof Individual)
          edges.addEdgeList( findAllValues( ind, (Individual)to, removedTypes, new DefaultEdge( inv, (Individual)to, ind, e.getDepends() ) ) ) ;
      }
    }
   
   
    return edges;
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.