コード例 #1
0
 public Hypothesis subsume(Hypothesis otherHypothesis) {
   LinkedList<Literal> newLiterals = new LinkedList<Literal>();
   for (Literal otherLiteral : otherHypothesis.literalMap.values()) {
     Literal correspondingLiteral = literalMap.get(otherLiteral.getAttribute());
     if (correspondingLiteral == null) {
       continue;
     }
     if (otherLiteral.equals(correspondingLiteral)) {
       newLiterals.add(otherLiteral);
       continue;
     }
     if (otherLiteral.contradicts(literalMap.get(otherLiteral.getAttribute()))) {
       return null;
     }
   }
   return new Hypothesis(newLiterals);
 }
コード例 #2
0
 @Override
 public boolean equals(Object object) {
   if (object == null) {
     return false;
   }
   if (getClass() != object.getClass()) {
     return false;
   }
   Hypothesis otherHypothesis = (Hypothesis) object;
   for (Literal literal : getLiterals()) {
     if (!literal.equals(otherHypothesis.getLiteral(literal.getAttribute()))) {
       return false;
     }
   }
   return true;
 }
コード例 #3
0
 public Hypothesis(Collection<Literal> literals) {
   this();
   for (Literal literal : literals) {
     literalMap.put(literal.getAttribute(), literal);
   }
 }