Esempio n. 1
0
  public ActMood mostSpecificGeneralization(CD that) {
    if (this == that || this.equals(that)) return this;
    if (!(that instanceof ActMood))
      throw new UnsupportedOperationException("cannot handle argument of class " + that.getClass());
    final ActMood thatActMood = (ActMood) that;

    // First build the intersection of the implied concepts
    // the remainder is a single path of which we have to
    // find the most specific concept, i.e., the one who
    // has all others as parents, i.e., the one with the
    // largest set of implied concepts.
    EnumSet<ActMood> intersection = EnumSet.copyOf(getImpliedConcepts());
    intersection.removeAll(EnumSet.complementOf(thatActMood.getImpliedConcepts()));
    intersection.remove(root);

    // XXX: this iterative search is likely to be least optimal because
    // we probably have to search the path from the root here.
    // I don't know of any better way to do it right now though.

    ActMood mostSpecificKnownGeneralization = root;
    int maxKnownSpecificity = 1;

    for (ActMood candidate : intersection) {
      int specificity = candidate.getImpliedConcepts().size();
      if (specificity > maxKnownSpecificity) {
        maxKnownSpecificity = specificity;
        mostSpecificKnownGeneralization = candidate;
      }
    }

    return mostSpecificKnownGeneralization;
  }
Esempio n. 2
0
 public BL implies(CD that) {
   if (this == that || this.equals(that)) return BLimpl.TRUE;
   if (!(that instanceof ActMood))
     throw new UnsupportedOperationException("cannot handle argument of class " + that.getClass());
   final ActMood thatActMood = (ActMood) that;
   return BLimpl.valueOf(getImpliedConcepts().contains(thatActMood));
 }