de.unima.alcomox.mapping
Class Alignment

java.lang.Object
  extended by de.unima.alcomox.mapping.Alignment
All Implemented Interfaces:
java.lang.Comparable<Alignment>, java.lang.Iterable<Correspondence>

public class Alignment
extends java.lang.Object
implements java.lang.Iterable<Correspondence>, java.lang.Comparable<Alignment>

A mapping is a ordered list of correspondences. It provided several set operations on the correspondences. As well as ordering and several operations like normalization and thresholding.


Constructor Summary
Alignment()
          Constructs a mapping with an empty list of correspondences.
Alignment(java.util.ArrayList<Correspondence> correspondences)
          Constructs a mapping with the given list of correspondences.
Alignment(java.util.Set<Correspondence> correspondencesAsSet)
          Constructs a mapping with the given set of correspondences.
 
Method Summary
 int applyThreshhold(float threshhold)
          Applies a threshold on the mapping by removing every correspondence with a confidence below the threhold.
 int compareTo(Alignment that)
           
 boolean equals(java.lang.Object object)
           
 Correspondence get(int index)
           
 double getConfidenceLowerBound()
           
 double getConfidenceTotal()
           
 double getConfidenceUpperBound()
           
 Alignment getCopy()
          Creates and returns a copy of this mapping.
 java.util.ArrayList<Correspondence> getCorrespondences()
          Returns the correspondences of this mapping as list.
 java.util.HashSet<Correspondence> getCorrespondencesAsSet()
          Returns the correspondences of this mapping as set.
 Alignment getDifference(Alignment that)
          Returns the set difference between this mapping and that mapping.
 Alignment getIntersection(Alignment that)
          Returns the intersection between this mapping and that.
static Alignment getJoinedMapping(Alignment[] mappings)
           
static Alignment getJoinedMapping(Alignment[] mappings, double[] weights)
           
 java.lang.String getMetaDescription()
          Returns different kinds of meta information about this mapping.
 Alignment getUnion(Alignment that)
          Returns the union of this mapping and that.
 int hashCode()
           
 void invert()
          Inverts this mapping.
 boolean isUnique()
           
 java.util.Iterator<Correspondence> iterator()
           
 void modifyToEquivalenceCorrespondences()
           
 void normalize()
          Normalizes the confidences of the correspondences to the range [0.0, 1.0].
 void normalize(double normConfidence)
           
 void normalize(double minBound, double maxBound)
          Normalizes the confidences of the correspondences to a given range.
 Correspondence pop()
           
 void push(Correspondence correspondence)
           
 void reduceToEquivalenceCorrespondences()
          Remove all correspondences from the mapping that express a different semantic relation than equivalence.
 Correspondence remove(int index)
           
 void removeCorrespondencesWithNSPrefix(java.lang.String ns)
           
 void setCorrespondences(java.util.ArrayList<Correspondence> correspondences)
          Sets a list of correspondences as correspondences of the mapping.
 void setCorrespondences(java.util.Set<Correspondence> correspondencesAsSet)
          Sets a set of correspondences as correspondences of the mapping.
 int size()
          Returns the size of the mapping.
 void sortDescending()
           
 java.lang.String toShortString()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Alignment

public Alignment()
Constructs a mapping with an empty list of correspondences.


Alignment

public Alignment(java.util.ArrayList<Correspondence> correspondences)
Constructs a mapping with the given list of correspondences.

Parameters:
correspondences - The correspondences of the mapping as list.

Alignment

public Alignment(java.util.Set<Correspondence> correspondencesAsSet)
Constructs a mapping with the given set of correspondences.

Parameters:
correspondences - The correspondences of the mapping as set.
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toShortString

public java.lang.String toShortString()

getMetaDescription

public java.lang.String getMetaDescription()
Returns different kinds of meta information about this mapping.

Returns:
Information about this mapping.

getConfidenceLowerBound

public double getConfidenceLowerBound()

getConfidenceUpperBound

public double getConfidenceUpperBound()

isUnique

public boolean isUnique()

getDifference

public Alignment getDifference(Alignment that)
Returns the set difference between this mapping and that mapping.

Parameters:
that - The mapping to be compared to this mapping.
Returns:
The set difference this without that.

getIntersection

public Alignment getIntersection(Alignment that)
Returns the intersection between this mapping and that.

Parameters:
that - The mapping to be intersected to this mapping.
Returns:
The intersection bewteen this and that.

getUnion

public Alignment getUnion(Alignment that)
Returns the union of this mapping and that.

Parameters:
that - The mapping to be unioned with this mapping.
Returns:
The union of this and that.

getCopy

public Alignment getCopy()
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.

Returns:
A copy of this mapping.

applyThreshhold

public int applyThreshhold(float threshhold)
Applies a threshold on the mapping by removing every correspondence with a confidence below the threhold.

Parameters:
threshhold - The threshold.
Returns:
The number of correspondences that have been removed.

normalize

public void normalize(double normConfidence)
               throws AlcomoException
Throws:
AlcomoException

normalize

public void normalize()
Normalizes the confidences of the correspondences to the range [0.0, 1.0].

Parameters:
minBound - The lower bound (inclusive) of the range.
maxBound - The upper bound (inclusive) of the range.

normalize

public void normalize(double minBound,
                      double maxBound)
Normalizes the confidences of the correspondences to a given range. If all correspondences have the same confidence, all of them are set to the upper bound of the range.

Parameters:
minBound - The lower bound (inclusive) of the range.
maxBound - The upper bound (inclusive) of the range.

invert

public void invert()
Inverts this mapping. This operation changes source and target entities of the correspondences as well as replaces the semantic relations with inverse relations.


setCorrespondences

public void setCorrespondences(java.util.ArrayList<Correspondence> correspondences)
Sets a list of correspondences as correspondences of the mapping.


setCorrespondences

public void setCorrespondences(java.util.Set<Correspondence> correspondencesAsSet)
Sets a set of correspondences as correspondences of the mapping.


getCorrespondences

public java.util.ArrayList<Correspondence> getCorrespondences()
Returns the correspondences of this mapping as list.

Returns:
The internally stored list of correspondences.

getCorrespondencesAsSet

public java.util.HashSet<Correspondence> getCorrespondencesAsSet()
Returns the correspondences of this mapping as set.

Returns:
The set of correspondences.

size

public int size()
Returns the size of the mapping.

Returns:
The size of the mapping in number of correspondences.

get

public Correspondence get(int index)

push

public void push(Correspondence correspondence)

pop

public Correspondence pop()

remove

public Correspondence remove(int index)

equals

public boolean equals(java.lang.Object object)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

iterator

public java.util.Iterator<Correspondence> iterator()
Specified by:
iterator in interface java.lang.Iterable<Correspondence>

sortDescending

public void sortDescending()

reduceToEquivalenceCorrespondences

public void reduceToEquivalenceCorrespondences()
Remove all correspondences from the mapping that express a different semantic relation than equivalence.


modifyToEquivalenceCorrespondences

public void modifyToEquivalenceCorrespondences()

getJoinedMapping

public static Alignment getJoinedMapping(Alignment[] mappings)
                                  throws PCFException,
                                         CorrespondenceException
Throws:
PCFException
CorrespondenceException

getJoinedMapping

public static Alignment getJoinedMapping(Alignment[] mappings,
                                         double[] weights)
                                  throws PCFException,
                                         CorrespondenceException
Throws:
PCFException
CorrespondenceException

getConfidenceTotal

public double getConfidenceTotal()

removeCorrespondencesWithNSPrefix

public void removeCorrespondencesWithNSPrefix(java.lang.String ns)

compareTo

public int compareTo(Alignment that)
Specified by:
compareTo in interface java.lang.Comparable<Alignment>
Returns:
-1 if this is less than that which is the case if trust of this is greater than trust of that