Package org.mindswap.pellet

Examples of org.mindswap.pellet.Individual


  }

  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();
          result = e;
View Full Code Here


    this.qualification = qualification;
        this.prevDS = new DependencySet[mergePairs.size()];
  }   
   
  public IndividualBranch copyTo(ABox abox) {
      Individual x = abox.getIndividual(ind.getName());
      MaxBranch b = new MaxBranch(abox, null, x, r, n, qualification, mergePairs, getTermDepends());
      b.setAnonCount( getAnonCount() );
      b.setNodeCount( nodeCount );
      b.setBranch( branch );
      b.setStrategy( strategy );
View Full Code Here

    if (abox.isInitialized()) {

      Iterator<Individual> i = getInitializeIterator();
      while (i.hasNext()) {
        Individual n = i.next();

        if (n.isMerged()) {
          continue;
        }

        if (n.isConceptRoot()) {
          applyUniversalRestrictions(n);
        }

        allValuesRule.apply(n);
        if (n.isMerged()) {
          continue;
        }
        nominalRule.apply(n);
        if (n.isMerged()) {
          continue;
        }
        selfRule.apply(n);

        // CHW-added for inc. queue must see if this is bad
        EdgeList allEdges = n.getOutEdges();
        for (int e = 0; e < allEdges.size(); e++) {
          Edge edge = allEdges.edgeAt(e);
          if (edge.getTo().isPruned()) {
            continue;
          }

          applyPropertyRestrictions(edge);
          if (n.isMerged()) {
            break;
          }
        }

      }

      return;
    }

    if (log.isLoggable(Level.FINE)) {
      log.fine("Initialize started");
    }

    abox.setBranch(0);

    mergeList.addAll(abox.getToBeMerged());

    if (!mergeList.isEmpty()) {
      mergeAll();
    }

    Role topRole = abox.getRole(TOP_OBJECT_PROPERTY);
    Iterator<Individual> i = getInitializeIterator();
    while (i.hasNext()) {
      Individual n = i.next();

      if (n.isMerged()) {
        continue;
      }

      applyUniversalRestrictions(n);
      if (n.isMerged()) {
        continue;
      }

      selfRule.apply(n);
      if (n.isMerged()) {
        continue;
      }

      EdgeList allEdges = n.getOutEdges();
      for (int e = 0; e < allEdges.size(); e++) {
        Edge edge = allEdges.edgeAt(e);

        if (edge.getTo().isPruned()) {
          continue;
        }

        applyPropertyRestrictions(edge);

        if (n.isMerged()) {
          break;
        }
      }

      if (n.isMerged()) {
        continue;
      }

      // The top object role isn't in the edge list, so pretend it exists
      applyPropertyRestrictions(n, topRole, n, DependencySet.INDEPENDENT);
View Full Code Here

   *
   */
  public abstract void complete(Expressivity expr);

  public Individual createFreshIndividual(Individual parent, DependencySet ds) {
    Individual ind = abox.addFreshIndividual(parent, ds);

    applyUniversalRestrictions(ind);

    return ind;
  }
View Full Code Here

      // note that we do not need to enforce the guess rule for
      // datatype properties because we may only have inverse
      // functional datatype properties which will be handled
      // inside applyPropertyRestrictions
      if (subj.isBlockable() && obj.isNominal() && !obj.isLiteral() && pred.isInverseFunctional()) {
        Individual o = (Individual) obj;
        int max = 1;
        if (!o.hasDistinctRNeighborsForMin(pred.getInverse(), max, ATermUtils.TOP, true)) {
          int guessMin = o.getMinCard(pred.getInverse(), ATermUtils.TOP);
          if (guessMin == 0) {
            guessMin = 1;
          }

          if (guessMin > max) {
View Full Code Here

    allValuesRule.applyAllValues(subj, pred, obj, ds);
    if (subj.isPruned() || obj.isPruned()) {
      return;
    }
    if (pred.isObjectRole()) {
      Individual o = (Individual) obj;
      allValuesRule.applyAllValues(o, pred.getInverse(), subj, ds);
      checkReflexivitySymmetry(subj, pred, o, ds);
      checkReflexivitySymmetry(o, pred.getInverse(), subj, ds);
      applyDisjointness(o, pred.getInverse(), subj, ds);
    }
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

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

    Individual head = null;
    DependencySet headDS = null;
    // find a nominal node to use as the head
    for (int edgeIndex = 0; edgeIndex < edges.size(); edgeIndex++) {
      Edge edge = edges.edgeAt(edgeIndex);
      Individual ind = edge.getFrom();

      if (ind.isNominal() && (head == null || ind.getNominalLevel() < head.getNominalLevel())) {
        head = ind;
        headDS = edge.getDepends();
      }
    }

    // if there is no nominal in the merge list we need to create one
    if (head == null) {
      head = abox.addFreshIndividual(null, ds);
    }
    else {
      ds = ds.union(headDS, abox.doExplanation());
    }

    for (int i = 0; i < edges.size(); i++) {
      Edge edge = edges.edgeAt(i);
      Individual next = edge.getFrom();

      if (next.isPruned()) {
        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;
      }

      ds = ds.union(edge.getDepends(), abox.doExplanation());

      if (next.isDifferent(head)) {
        ds = ds.union(next.getDifferenceDependency(head), abox.doExplanation());
        if (r.isFunctional()) {
          abox.setClash(Clash.functionalCardinality(x, ds, r.getName()));
        }
        else {
          abox.setClash(Clash.maxCardinality(x, ds, r.getName(), 1));
View Full Code Here

    // for all edges (z, r, y) add an edge (z, r, x)
    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
        if (abox.getBranch() >= 0 && PelletOptions.TRACK_BRANCH_EFFECTS) {
          abox.getBranchEffectTracker().add(abox.getBranch(), z.getName());
        }

        // do not remove edge here because prune will take care of that
      }
    }
View Full Code Here

    findNext();
  }

  public Individual next() {
    findNext();
    Individual ind = abox.getIndividual(nodeList.get(index++));
   
    return ind;
  }
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.