Exemplo n.º 1
0
 public static Alignment getJoinedMapping(Alignment[] mappings, double[] weights)
     throws PCFException, CorrespondenceException {
   if (mappings.length != weights.length) {
     throw new PCFException(
         PCFException.INVALID_PARAM_COMBINATION,
         "in a mapping join operation you need the same number of mappings and weights");
   }
   HashMap<Correspondence, Double> hashedConfidences = new HashMap<Correspondence, Double>();
   for (int m = 0; m < mappings.length; m++) {
     double weight = weights[m];
     for (Correspondence c : mappings[m]) {
       if (hashedConfidences.containsKey(c)) {
         hashedConfidences.put(c, c.getConfidence() * weight + hashedConfidences.get(c));
       } else {
         hashedConfidences.put(c, c.getConfidence() * weight);
       }
     }
   }
   Alignment joinedMapping = new Alignment();
   for (Correspondence c : hashedConfidences.keySet()) {
     c.setConfidence(hashedConfidences.get(c));
     joinedMapping.push(c);
   }
   return joinedMapping;
 }
Exemplo n.º 2
0
 /**
  * Creates and returns a copy of this mapping. Te copy has ist own list of correspondences, but
  * contains references to the same correspondences as are referred to be this mapping.
  *
  * @return A copy of this mapping.
  */
 public Alignment getCopy() {
   Alignment copy = new Alignment();
   for (Correspondence c : this) {
     copy.push(c);
   }
   if (this.idPattern != null) {
     copy.idPattern = new boolean[this.idPattern.length];
     for (int i = 0; i < this.idPattern.length; i++) {
       copy.idPattern[i] = this.idPattern[i];
     }
   }
   return copy;
 }