Ejemplo 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;
 }
Ejemplo 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;
 }
Ejemplo n.º 3
0
 /**
  * @return -1 if this is less than that which is the case if trust of this is greater than trust
  *     of that
  */
 public int compareTo(Alignment that) {
   double thisTrust = this.getConfidenceTotal();
   double thatTrust = that.getConfidenceTotal();
   if (thisTrust < thatTrust) {
     return 1;
   } else if (thisTrust == thatTrust) {
     return 0;
   } else {
     return -1;
   }
 }
Ejemplo n.º 4
0
 /**
  * Returns the union of this mapping and that.
  *
  * @param that The mapping to be unioned with this mapping.
  * @return The union of this and that.
  */
 public Alignment getUnion(Alignment that) {
   HashSet<Correspondence> thisCSet = this.getCorrespondencesAsSet();
   HashSet<Correspondence> thatCSet = that.getCorrespondencesAsSet();
   thisCSet.addAll(thatCSet);
   return (new Alignment(thisCSet));
 }
Ejemplo n.º 5
0
 /**
  * Returns the intersection between this mapping and that.
  *
  * @param that The mapping to be intersected to this mapping.
  * @return The intersection bewteen this and that.
  */
 public Alignment getIntersection(Alignment that) {
   HashSet<Correspondence> thisCSet = this.getCorrespondencesAsSet();
   HashSet<Correspondence> thatCSet = that.getCorrespondencesAsSet();
   thisCSet.retainAll(thatCSet);
   return (new Alignment(thisCSet));
 }
Ejemplo n.º 6
0
 /**
  * Returns the set difference between this mapping and that mapping.
  *
  * @param that The mapping to be compared to this mapping.
  * @return The set difference this without that.
  */
 public Alignment getDifference(Alignment that) {
   HashSet<Correspondence> thisCSet = this.getCorrespondencesAsSet();
   HashSet<Correspondence> thatCSet = that.getCorrespondencesAsSet();
   thisCSet.removeAll(thatCSet);
   return (new Alignment(thisCSet));
 }