コード例 #1
0
ファイル: Alignment.java プロジェクト: anukat2015/Swip
 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;
 }
コード例 #2
0
ファイル: Alignment.java プロジェクト: anukat2015/Swip
 public void normalize(double normConfidence) throws AlcomoException {
   for (Correspondence c : this.correspondences) {
     c.setConfidence(normConfidence);
   }
 }