Package org.mindswap.pellet

Examples of org.mindswap.pellet.Role


            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 );
          ds = ds.union( subDS, strategy.getABox().doExplanation() );
                  ds = ds.union( edge.getDepends(), strategy.getABox().doExplanation() );
                  ds = ds.union( typeDS, strategy.getABox().doExplanation() );
                 
View Full Code Here


        Set<Role> functionalSupers = s.getFunctionalSupers();
        if( functionalSupers.isEmpty() )
            functionalSupers = SetUtils.singleton( s );
        LOOP:
        for( Iterator<Role> it = functionalSupers.iterator(); it.hasNext(); ) {
            Role r = it.next();

            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;

                // it is possible that there are multiple edges to the same
                // node, e.g. property p and its super property, so check if
                // we already merged this one
                if( head.isSame( next ) )
                    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( next.getDepends( c ), strategy.getABox().doExplanation() );
                ds = ds.union( r.getExplainSubOrInv( edge.getRole() ), strategy.getABox().doExplanation() );

                if( next.isDifferent( head ) ) {
                    ds = ds.union( head.getDepends( c ), strategy.getABox().doExplanation() );
                    ds = ds.union( next.getDepends( c ), strategy.getABox().doExplanation() );
                    ds = ds.union( next.getDifferenceDependency( head ), strategy.getABox().doExplanation() );
                    if( r.isFunctional() )
                        strategy.getABox().setClash( Clash.functionalCardinality( x, ds, r.getName() ) );
                    else
                        strategy.getABox().setClash( Clash.maxCardinality( x, ds, r.getName(), 1 ) );

                    break;
                }

                if( x.isNominal() && head.isBlockable() && next.isBlockable()
View Full Code Here

      return;
 
    // get the object
    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 );
View Full Code Here

            throw new InternalReasonerException();
        ATerm p = av.getArgument( 0 );
        ATermAppl c = (ATermAppl) av.getArgument( 1 );       
       
        ATermList roleChain = ATermUtils.EMPTY_LIST;
        Role s = null;
        if( p.getType() == ATerm.LIST ) {
            roleChain = (ATermList) p;
            s = strategy.getABox().getRole( roleChain.getFirst() );
            roleChain = roleChain.getNext();
        }
        else
            s = strategy.getABox().getRole( p );

        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 );
            else if(y.isIndividual()) {
                ATermAppl allRC = ATermUtils.makeAllValues( roleChain, c );

                strategy.addType( y, allRC, finalDS );
            }

            if( x.isMerged() || strategy.getABox().isClosed() )
                return;
        }

        if( !s.isSimple() ) {
            Set<ATermList> subRoleChains = s.getSubRoleChains();
            for( Iterator<ATermList> it = subRoleChains.iterator(); it.hasNext(); ) {
                ATermList chain = it.next();
                DependencySet subChainDS = ds.union(s.getExplainSub(chain), strategy.getABox().doExplanation() );
        if (!applyAllValuesPropertyChain(x, chain, c, subChainDS))
          return;
            }
        }
       
View Full Code Here

        // timer.stop();
    }

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

            ATerm p = av.getArgument( 0 );
            ATermAppl c = (ATermAppl) av.getArgument( 1 );
           
            ATermList roleChain = ATermUtils.EMPTY_LIST;
            Role s = null;
            if( p.getType() == ATerm.LIST ) {
                roleChain = (ATermList) p;
                s = strategy.getABox().getRole( roleChain.getFirst() );
                roleChain = roleChain.getNext();
            }
            else
                s = strategy.getABox().getRole( p );
                       
            if ( s.isTop() && s.isObjectRole() ) {
              applyAllValuesTop( av, c, ds );
              if( strategy.getABox().isClosed() )
                    return;
              continue;
            }

            if( pred.isSubRoleOf( s ) ) {
                DependencySet finalDS = subj.getDepends( av );
        finalDS = finalDS.union( ds, strategy.getABox().doExplanation() );
        finalDS = finalDS.union( s.getExplainSubOrInv( pred ), strategy.getABox().doExplanation() );
                if( roleChain.isEmpty() )
                    applyAllValues( subj, s, obj, c, finalDS );
                else if (obj.isIndividual()) {
                    ATermAppl allRC = ATermUtils.makeAllValues( roleChain, c );

                    strategy.addType( obj, allRC, finalDS );
                }
               
                if( strategy.getABox().isClosed() )
                    return;
            }

            if( !s.isSimple() ) {
                DependencySet finalDS = subj.getDepends( av ).union( ds, strategy.getABox().doExplanation() );
                Set<ATermList> subRoleChains = s.getSubRoleChains();
                for( Iterator<ATermList> it = subRoleChains.iterator(); it.hasNext(); ) {
                    ATermList chain = it.next();
                   
//                    if( !pred.getName().equals( chain.getFirst() ) )
                    Role firstRole = strategy.getABox().getRole(chain.getFirst());
                    if( !pred.isSubRoleOf( firstRole ) )
                        continue;

                    ATermAppl allRC = ATermUtils.makeAllValues( chain.getNext(), c );

                    applyAllValues( subj, pred, obj, allRC, finalDS.union(
                        firstRole.getExplainSub(pred.getName()), strategy.getABox().doExplanation()).union(
                            s.getExplainSub(chain), strategy.getABox().doExplanation() ) );

                    if( subj.isMerged() || strategy.getABox().isClosed() )
                        return;
                }
View Full Code Here

       */
      if (rTerm instanceof ATermList)
        continue;
     
      final ATermAppl r = (ATermAppl)rTerm;
      final Role role = strategy.getABox().getRole( r );
     
      /*
       * Skip any roles that are not datatype properties
       */
      if (!role.isDatatypeRole())
        continue;
     
      /*
       * Collect the data range and its dependency set
       */
      Collection<ATermAppl> existing = dataranges.get( r );
      DependencySet ds = x.getDepends( allDesc );
      if (existing == null) {
        existing = new ArrayList<ATermAppl>();
        dataranges.put( r, existing );
      } else {
        ds = ds.union( rangeDepends.get( r ), strategy.getABox().doExplanation() );
      }
      existing.add( (ATermAppl) allDesc.getArgument(1) );
      rangeDepends.put( r, ds );

    }

    /*
     * Get the ranges of any data properties that have min cardinality restrictions
     */
    for (ATermAppl minDesc : x.getTypes( Node.MIN )) {
      /*
       * TODO: Verify that minDesc will never have a property chain
       */
      final ATermAppl r = (ATermAppl)minDesc.getArgument( 0 );
      final Role role = strategy.getABox().getRole( r );
     
      /*
       * Skip any roles that are not datatype properties
       */
      if (!role.isDatatypeRole())
        continue;

      final Set<ATermAppl> ranges = role.getRanges();
      if( !ranges.isEmpty() ) {
        Collection<ATermAppl> existing = dataranges.get( r );
        DependencySet ds;
        if( existing == null ) {
          existing = new ArrayList<ATermAppl>();
          dataranges.put( r, existing );
          ds = DependencySet.EMPTY;
        } else
          ds = rangeDepends.get( r );

        for( ATermAppl dataRange : role.getRanges() ) {
          /*
           * TODO: Verify the dependency set handling here. The old
           * implementation just used independent (thus could avoid
           * this loop and call addAll)
           */
          existing.add( dataRange );
          ds = ds.union( role.getExplainRange( dataRange ), strategy.getABox().doExplanation() );
          rangeDepends.put( r, ds );
        }
      }
    }

    /*
     * For each of the min cardinality restrictions, verify that the data range is large enough
     */
    for (ATermAppl minDesc : x.getTypes( Node.MIN )) {
      final ATermAppl r = (ATermAppl)minDesc.getArgument( 0 );
      final Role role = strategy.getABox().getRole( r );

      Set<ATermAppl> drs = new HashSet<ATermAppl>();
      Collection<ATermAppl> direct = dataranges.get( r );
      DependencySet ds;
      if (direct != null) {
        drs.addAll(direct);
        ds = rangeDepends.get( r );
      } else
        ds = DependencySet.EMPTY;
     
      ds = ds.union(x.getDepends(minDesc), strategy.getABox().doExplanation() );

      for (Role superRole : role.getSuperRoles()) {
        final ATermAppl s = superRole.getName();
        Collection<ATermAppl> inherited = dataranges.get( s );
        if( inherited != null ) {
          drs.addAll( inherited );
          ds = ds.union( rangeDepends.get( s ), strategy.getABox().doExplanation() ).union(
              role.getExplainSuper( s ), strategy.getABox().doExplanation() );
        }
      }

      if( !drs.isEmpty() ) {
        final int n = ((ATermInt)minDesc.getArgument( 1 )).getInt();
View Full Code Here

          }
          else if( kb.isDatatype( term ) ) {
            types.add( RDFS.Datatype.asNode() );
          }
          else if( kb.isObjectProperty( term ) ) {
            Role role = kb.getRole( term );
            types.add( OWL.ObjectProperty.asNode() );
            if( role.isFunctional() )
              types.add( OWL.FunctionalProperty.asNode() );
            if( role.isInverseFunctional() )
              types.add( OWL.InverseFunctionalProperty.asNode() );
            if( role.isTransitive() )
              types.add( OWL.TransitiveProperty.asNode() );
            if( role.isSymmetric() )
              types.add( OWL.SymmetricProperty.asNode() );
            if( role.isAsymmetric() )
              types.add( OWL2.AsymmetricProperty.asNode() );
            if( role.isReflexive() )
              types.add( OWL2.ReflexiveProperty.asNode() );
            if( role.isIrreflexive() )
              types.add( OWL2.IrreflexiveProperty.asNode() );
          }
          else if( kb.isDatatypeProperty( term ) ) {         
            Role role = kb.getRole( term );
            types.add( OWL.DatatypeProperty.asNode() );
            if( role.isFunctional() )
              types.add( OWL.FunctionalProperty.asNode() );
            if( role.isInverseFunctional() )
              types.add( OWL.InverseFunctionalProperty.asNode() );
          }
          else if( kb.isAnnotationProperty( term ) ) {
            types.add( OWL.AnnotationProperty.asNode() );           
          }
View Full Code Here

    return unsupportedFeatures;
  }

  protected void addSimpleProperty(ATermAppl p, SimpleProperty why) {
    simpleProperties.put( p, why );
    Role role = kb.getRBox().getRole( p );
    role.setForceSimple( true );
  }
View Full Code Here

    ATermAppl st = node2term( s );
    ATermAppl ot = node2term( o );

    if( builtinTerm == null ) {
      ATermAppl pt = node2term( p );
      Role role = kb.getProperty( pt );
      PropertyType type = (role == null)
        ? PropertyType.UNTYPED
        : role.getType();

      if( type == PropertyType.ANNOTATION ) {
        // Skip ontology annotations
        if( graph.contains( s, RDF.type.asNode(), OWL.Ontology.asNode() ) ) {
                  return;
View Full Code Here

TOP

Related Classes of org.mindswap.pellet.Role

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.