Package org.mindswap.pellet

Examples of org.mindswap.pellet.Role


  void applyUniversalRestrictions(Individual node) {
    addType(node, ATermUtils.TOP, DependencySet.INDEPENDENT);

    Set<Role> reflexives = abox.getKB().getRBox().getReflexiveRoles();
    for (Iterator<Role> i = reflexives.iterator(); i.hasNext();) {
      Role r = i.next();
      if (log.isLoggable(Level.FINE) && !node.hasRNeighbor(r, node)) {
        log.fine("REF : " + node + " " + r);
      }
      addEdge(node, r, node, r.getExplainReflexive());
      if (node.isMerged()) {
        return;
      }
    }

    Role topObjProp = abox.getKB().getRole(ATermUtils.TOP_OBJECT_PROPERTY);
    for (ATermAppl domain : topObjProp.getDomains()) {
      addType(node, domain, topObjProp.getExplainDomain(domain));
      if (node.isMerged()) {
        continue;
      }
    }
    for (ATermAppl range : topObjProp.getRanges()) {
      addType(node, range, topObjProp.getExplainRange(range));
      if (node.isMerged()) {
        continue;
      }
    }
View Full Code Here


    else if (c.getAFun().equals(ATermUtils.ALLFUN)) {
      allValuesRule.applyAllValues((Individual) node, c, ds);
    }
    else if (c.getAFun().equals(ATermUtils.SELFFUN)) {
      ATermAppl pred = (ATermAppl) c.getArgument(0);
      Role role = abox.getRole(pred);
      if (log.isLoggable(Level.FINE) && !((Individual) node).hasRSuccessor(role, node)) {
        log.fine("SELF: " + node + " " + role + " " + node.getDepends(c));
      }
      addEdge((Individual) node, role, node, ds);
    }
View Full Code Here

    List<ATermAppl> types = subj.getTypes(Node.MAX);
    int size = types.size();
    for (int j = 0; j < size; j++) {
      ATermAppl c = types.get(j);
      ATermAppl max = (ATermAppl) c.getArgument(0);
      Role r = abox.getRole(max.getArgument(0));
      if (pred.isSubRoleOf(r)) {
        QueueElement newElement = new QueueElement(subj, c);
        abox.getCompletionQueue().add(newElement, NodeSelector.MAX_NUMBER);
        abox.getCompletionQueue().add(newElement, NodeSelector.CHOOSE);
      }
    }

    // if the predicate has an inverse or is inversefunctional and the obj
    // is an individual, then add the object to the list.
    if (obj instanceof Individual) {
      types = ((Individual) obj).getTypes(Node.MAX);
      size = types.size();
      for (int j = 0; j < size; j++) {
        ATermAppl c = types.get(j);
        ATermAppl max = (ATermAppl) c.getArgument(0);
        Role r = abox.getRole(max.getArgument(0));

        Role invR = pred.getInverse();

        if (invR != null) {
          if (invR.isSubRoleOf(r)) {
            QueueElement newElement = new QueueElement(obj, c);
            abox.getCompletionQueue().add(newElement, NodeSelector.MAX_NUMBER);
            abox.getCompletionQueue().add(newElement, NodeSelector.CHOOSE);
          }
        }
View Full Code Here

    if (pred.isDatatypeRole() && pred.isInverseFunctional()) {
      applyFunctionalMaxRule((Literal) obj, pred, DependencySet.INDEPENDENT);
    }
    else if (pred.isObjectRole()) {
      Individual val = (Individual) obj;
      Role invR = pred.getInverse();

      maxCardDS = invR.isFunctional() ? invR.getExplainFunctional() : val.hasMax1(invR);

      if (maxCardDS != null) {
        maxRule.applyFunctionalMaxRule(val, invR, ATermUtils.TOP, maxCardDS);
      }
    }
View Full Code Here

    EdgeList inEdges = y.getInEdges();
    for (int e = 0; e < inEdges.size(); e++) {
      Edge edge = inEdges.edgeAt(e);

      Individual z = edge.getFrom();
      Role r = edge.getRole();
      DependencySet finalDS = ds.union(edge.getDepends(), abox.doExplanation());

      // if y has a self edge then x should have the same self edge
      if (y.equals(z)) {
        addEdge(x, r, x, finalDS);
      }
      // if z is already a successor of x add the reverse edge
      else if (x.hasSuccessor(z)) {
        // FIXME what if there were no inverses in this expressitivity
        addEdge(x, r.getInverse(), z, finalDS);
      }
      else {
        addEdge(z, r, x, finalDS);
      }

      // only remove the edge from z and keep a copy in y for a
      // possible restore operation in the future
      z.removeEdge(edge);

      // add to effected list of queue
      // if( abox.getBranch() >= 0 && PelletOptions.USE_COMPLETION_QUEUE ) {
      // abox.getCompletionQueue().addEffected( abox.getBranch(), z.getName() );
      // }
      if (abox.getBranch() >= 0 && PelletOptions.TRACK_BRANCH_EFFECTS) {
        abox.getBranchEffectTracker().add(abox.getBranch(), z.getName());
      }

    }

    // for all z such that y != z set x != z
    x.inheritDifferents(y, ds);

    // we want to prune y early due to an implementation issue about literals
    // if y has an outgoing edge to a literal with concrete value
    y.prune(ds);

    // for all edges (y, r, z) where z is a nominal add an edge (x, r, z)
    EdgeList outEdges = y.getOutEdges();
    for (int e = 0; e < outEdges.size(); e++) {
      Edge edge = outEdges.edgeAt(e);
      Node z = edge.getTo();

      if (z.isNominal() && !y.equals(z)) {
        Role r = edge.getRole();
        DependencySet finalDS = ds.union(edge.getDepends(), abox.doExplanation());

        addEdge(x, r, z, finalDS);

        // add to effected list
View Full Code Here

    EdgeList inEdges = y.getInEdges();
    for (int e = 0; e < inEdges.size(); e++) {
      Edge edge = inEdges.edgeAt(e);

      Individual z = edge.getFrom();
      Role r = edge.getRole();
      DependencySet finalDS = ds.union(edge.getDepends(), abox.doExplanation());

      addEdge(z, r, x, finalDS);

      // only remove the edge from z and keep a copy in y for a
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;

      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

  /**
   * {@inheritDoc}
   */
  public boolean isSafe(ATermAppl c, Individual ind) {
    Edge parentEdge = getParentEdge( ind );
    Role r = parentEdge.getRole();
    Individual parent = parentEdge.getFrom();
   
    ABox abox = parent.getABox();

    if( !isParentSafe( abox.getKB(), r, parent ) )
      return false;

    Iterator<CachedNode> nodes = getCachedNodes( abox, c );

    if( !nodes.hasNext() )
      return false;

    if( interactsWithInverses( abox.getKB(), r ) ) {
      while( nodes.hasNext() ) {
        CachedNode node = nodes.next();

        if( node.isBottom() )
          return true;
        else if( node.isTop() || !node.isComplete() )
          return false;

        if( !isSafe( abox.getKB(), parent, r.getInverse(), node ) )
          return false;
      }
    }

    return true;
View Full Code Here

    return true;
  }

  protected Edge getParentEdge(Individual ind) {
    Edge result = null;
    Role role = null;
    Individual parent = ind.getParent();
    for( Edge e : ind.getInEdges() ) {
      if( e.getFrom().equals( parent ) ) {
        if( role == null ) {
          role = e.getRole();
View Full Code Here

    return true;
  }

  private boolean isParentMaxSafe(KnowledgeBase kb, Role role, ATermAppl max) {
    Role maxR = kb.getRole( max.getArgument( 0 ) );

    return !role.isSubRoleOf( maxR );
  }
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.