java.lang.Object
de.uni_mannheim.informatik.dws.melt.yet_another_alignment_api.Correspondence
All Implemented Interfaces:
Comparable<Correspondence>

public class Correspondence extends Object implements Comparable<Correspondence>
A Correspondence contains a relation that holds between two elements from two different ontologies. This is also known as "Mapping Cell" or "Cell". It is uniquely identified by entityOne, entityTwo and relation.
Author:
Sven Hertling, Jan Portisch
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • entityOne

      protected String entityOne
    • entityTwo

      protected String entityTwo
    • confidence

      protected double confidence
    • relation

      protected CorrespondenceRelation relation
    • identifier

      protected String identifier
    • extensions

      protected Map<String,Object> extensions
    • CONFIDENCE_KEY_PATTERN

      private static final Pattern CONFIDENCE_KEY_PATTERN
    • EXPLANATION_KEY_PATTERN

      private static final Pattern EXPLANATION_KEY_PATTERN
    • SOURCE

      public static final com.googlecode.cqengine.attribute.Attribute<Correspondence,String> SOURCE
    • TARGET

      public static final com.googlecode.cqengine.attribute.Attribute<Correspondence,String> TARGET
    • RELATION

      public static final com.googlecode.cqengine.attribute.Attribute<Correspondence,CorrespondenceRelation> RELATION
    • CONFIDENCE

      public static final com.googlecode.cqengine.attribute.Attribute<Correspondence,Double> CONFIDENCE
  • Constructor Details

    • Correspondence

      public Correspondence(String entityOne, String entityTwo, double confidence, CorrespondenceRelation relation, Map<String,Object> extensions, String identifier)
      Constructor
      Parameters:
      entityOne - URI of the entity from the source ontology as String.
      entityTwo - URI of the entity from the target ontology as String.
      confidence - The confidence of the mapping.
      relation - The relation that holds between the two entities.
      identifier - The unique identifier for the mapping.
      extensions - extensions in the form of a map
    • Correspondence

      public Correspondence(String entityOne, String entityTwo, double confidence, CorrespondenceRelation relation, Object... extensions)
      Constructor The identifier is set to null by default.
      Parameters:
      entityOne - URI of the entity from the source ontology as String.
      entityTwo - URI of the entity from the target ontology as String.
      confidence - The confidence of the mapping.
      relation - The relation that holds between the two entities.
      extensions - extensions in key1, value1, key2, value2, ... format
    • Correspondence

      public Correspondence(String entityOne, String entityTwo, double confidence, CorrespondenceRelation relation, Map<String,Object> extensions)
      Constructor The identifier is set to null by default.
      Parameters:
      entityOne - URI of the entity from the source ontology as String.
      entityTwo - URI of the entity from the target ontology as String.
      confidence - The confidence of the mapping.
      relation - The relation that holds between the two entities.
      extensions - extensions as a map of key to value (both strings)
    • Correspondence

      public Correspondence(String entityOne, String entityTwo, double confidence, Object... extensions)
      Constructor The identifier is set to null by default.
      Parameters:
      entityOne - URI of the entity from the source ontology as String.
      entityTwo - URI of the entity from the target ontology as String.
      confidence - The confidence of the mapping.
      extensions - extensions in key1, value1, key2, value2, ... format
    • Correspondence

      public Correspondence(String entityOne, String entityTwo, double confidence, CorrespondenceRelation relation)
      Constructor The identifier is set to null by default.
      Parameters:
      entityOne - URI of the entity from the source ontology as String.
      entityTwo - URI of the entity from the target ontology as String.
      confidence - The confidence of the mapping.
      relation - The relation that holds between the two entities.
    • Correspondence

      public Correspondence(String entityOne, String entityTwo, double confidence)
      Constructor The relation that holds between the two entities is assumed to be CorrespondenceRelation.EQUIVALENCE. The identifier is set to null by default.
      Parameters:
      entityOne - URI of the entity from the source ontology as String.
      entityTwo - URI of the entity from the target ontology as String.
      confidence - The confidence of the mapping.
    • Correspondence

      public Correspondence(String entityOne, String entityTwo, CorrespondenceRelation relation)
      Constructor The identifier is set to null by default. The confidence is assumed to be 1.0.
      Parameters:
      entityOne - URI of the entity from the source ontology as String.
      entityTwo - URI of the entity from the target ontology as String.
      relation - The relation that holds between the two entities.
    • Correspondence

      public Correspondence(String entityOne, String entityTwo)
      Constructor The relation that holds between the two entities is assumed to be CorrespondenceRelation.EQUIVALENCE. The identifier is set to null by default. The confidence is assumed to be 1.0.
      Parameters:
      entityOne - URI of the entity from the source ontology as String.
      entityTwo - URI of the entity from the target ontology as String.
    • Correspondence

      Correspondence()
      Constructor for empty correspondence initialization by AlignmentParser.
    • Correspondence

      public Correspondence(Correspondence other)
      Copy constructor for correspondences. Important: Copies the extensions only shallow. This menas the objetc values of the hashmap are shared (pointing to the same object).
      Parameters:
      other - the other correspondence
  • Method Details

    • parseExtensions

      private static Map<String,Object> parseExtensions(Object[] arr)
    • reverseWithoutRelationChange

      public Correspondence reverseWithoutRelationChange()
      This method returns a NEW correspondence where the source and target are reversed but not the relation.
      Returns:
      New reversed correspondence.
    • reverse

      public Correspondence reverse()
      This method returns a NEW correspondence with a reversed relation. For example CorrespondenceRelation.SUBSUME will be reversed to CorrespondenceRelation.SUBSUMED. If only the source and target should be reversed, use reverseWithoutRelationChange() method.
      Returns:
      New reversed correspondence.
    • getExtensionValue

      public Object getExtensionValue(String extensionUri)
      Obtain the value of an extension.
      Parameters:
      extensionUri - The URI identifying the extension.
      Returns:
      The value of the extension as String, null if there is no value.
    • getExtensionValueAsString

      public String getExtensionValueAsString(String extensionUri)
      Obtain the value of an extension as string.
      Parameters:
      extensionUri - The URI identifying the extension.
      Returns:
      The value of the extension as String, null if there is no value.
    • getExtensionValueCasted

      public <T> T getExtensionValueCasted(String extensionUri)
      Obtain the value of an extension.
      Type Parameters:
      T - Extension value type.
      Parameters:
      extensionUri - The URI identifying the extension.
      Returns:
      The value of the extension as String, null if there is no value.
    • getExtensionValueCasted

      public <T> T getExtensionValueCasted(Object extensionUri)
      Obtain the value of an extension.
      Type Parameters:
      T - Extension value type.
      Parameters:
      extensionUri - The URI identifying the extension.
      Returns:
      The value of the extension as String, null if there is no value.
    • addExtensionValue

      public void addExtensionValue(String extensionUri, Object extensionValue)
      Set the value for an extension. Possible keys are defined in class DefaultExtensions.
      Parameters:
      extensionUri - The URI identifying the extension. Possible keys are defined in class DefaultExtensions.
      extensionValue - The value of the extension to be set.
    • addExtensionValue

      public void addExtensionValue(Object extensionUri, Object extensionValue)
      Set the value for an extension. Possible keys are defined in class DefaultExtensions.
      Parameters:
      extensionUri - The URI identifying the extension. Possible keys are defined in class DefaultExtensions.
      extensionValue - The value of the extension to be set.
    • addAdditionalConfidence

      public void addAdditionalConfidence(Class<?> matcherClass, double confidence)
      Adds an additional confidence based on a specific class.
      Parameters:
      matcherClass - the class of the matcher
      confidence - the additional confidence
    • addAdditionalConfidence

      public void addAdditionalConfidence(String key, double confidence)
      Adds an additional confidence associated with any specific string value. This should be used if one class puts multiple confidence values.
      Parameters:
      key - the key which should be associated with the confidence
      confidence - the additional confidence
    • addAdditionalConfidenceIfHigher

      public void addAdditionalConfidenceIfHigher(String key, double confidence)
      Adds an additional confidence associated with any specific string value only if the confidence is higher. This should be used if one class puts multiple confidence values.
      Parameters:
      key - the key which should be associated with the confidence
      confidence - the additional confidence
    • addAdditionalConfidenceIfHigher

      public void addAdditionalConfidenceIfHigher(Class<?> matcherClass, double confidence)
      Adds an additional confidence based on a specific class only if the confidence is higher.
      Parameters:
      matcherClass - the class of the matcher
      confidence - the additional confidence
    • getAdditionalConfidence

      public Double getAdditionalConfidence(Class<?> matcherClass)
      Get a confidence given the name of the matcher.
      Parameters:
      matcherClass - Class of the matcher.
      Returns:
      The confidence if found.
    • getAdditionalConfidence

      public Double getAdditionalConfidence(String key)
      Returns the additional confidence based on the key (which is used in addAdditionalConfidence). The key is NOT the full URL in the correspondence extensions.
      Parameters:
      key - part of the confidence URL
      Returns:
      the confidence or null if not existent
    • getAdditionalConfidenceOrDefault

      public double getAdditionalConfidenceOrDefault(String key, double defaultValue)
    • getAdditionalConfidenceURL

      public static String getAdditionalConfidenceURL(String key)
      Returns the full URL for an additional confidence. The key is just a part of the full URL.
      Parameters:
      key - the key which is a part of the full URL.
      Returns:
      the full URL
    • getAdditionalConfidences

      public Map<String,Double> getAdditionalConfidences()
      Returns all added confidences (but not all extension values). The key of the returned map contains just the name of the confidence and is not the full URL contained in correspondence extensions.
      Returns:
      All confidences that were added using e.g. addAdditionalConfidence(String, double).
    • addAdditionalExplanation

      public void addAdditionalExplanation(Class<?> matcherClass, String explanation)
      Adds an additional explanation
      Parameters:
      matcherClass - the class of the matcher
      explanation - the explanation for a correspondence
    • addAdditionalExplanation

      public void addAdditionalExplanation(String key, String explanation)
      Adds an additional explanation
      Parameters:
      key - the key which should be associated with the explanation
      explanation - the explanation for a correspondence
    • getAdditionalExplanation

      public String getAdditionalExplanation(Class<?> matcherClass)
    • getAdditionalExplanation

      public String getAdditionalExplanation(String key)
    • getAdditionalExplanationURL

      public static String getAdditionalExplanationURL(String key)
      Returns the full URL for an additional explanation. The key is just a part of the full URL.
      Parameters:
      key - the key which is a part of the full URL.
      Returns:
      the full URL
    • getAdditionalExplanations

      public Map<String,String> getAdditionalExplanations()
    • removeExtensions

      public void removeExtensions()
      Clears the extension of this correspondence.
    • removeExtensions

      public void removeExtensions(Iterable<String> blacklist)
      Remove all extensions which appear in blacklist.
      Parameters:
      blacklist - the extension keys to be removed.
    • removeExtensionsNotIn

      public void removeExtensionsNotIn(Set<String> whitelist)
      Removes all extensions, but keep the extensions with keys appearing in whitelist.
      Parameters:
      whitelist - the extensions keys which should be kept
    • getExtensions

      public Map<String,Object> getExtensions()
    • getEntityOne

      public String getEntityOne()
    • setEntityOne

      public void setEntityOne(String entityOne)
    • getEntityTwo

      public String getEntityTwo()
    • setEntityTwo

      public void setEntityTwo(String entityTwo)
    • getConfidence

      public double getConfidence()
    • setConfidence

      public void setConfidence(double confidence)
    • getRelation

      public CorrespondenceRelation getRelation()
    • setRelation

      public void setRelation(CorrespondenceRelation relation)
    • getIdentifier

      public String getIdentifier()
    • setIdentifier

      public void setIdentifier(String identifier)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toStringWithExtensions

      public String toStringWithExtensions()
    • comparingByConfidence

      public static Comparator<Correspondence> comparingByConfidence()
    • compareTo

      public int compareTo(Correspondence that)
      Specified by:
      compareTo in interface Comparable<Correspondence>