Interface SimilarityModel

All Known Implementing Classes:
SimilarityModelImpl

public interface SimilarityModel

Data Similarity Model

The similarity model contains for each DataClass  a set of similarity measures. Each SimilarityMeasure  must have a unique name for one DataClass. The Retriever uses, if not defined otherwise, the default SimilarityMeasure. The default similarity measure can be defined with the method setDefaultSimilarityMeasure(DataClass, String).

Creating a new similarity measure

To assign a new SimilarityMeasure to a DataClass object it must be first created with createSimilarityMeasure(String, DataClass) and than added to the similarity model with addSimilarityMeasure(SimilarityMeasure, String).

      SimilarityMeasure sm = simModel.createSimilarityMeasure(SMAggregateAverage.NAME, dataClass);
      simModel.addSimilarityMeasure(sm, "defaultSimMeasure");
      simModel.setDefaultSimilarityMeasure(sm, "defaultSimMeasure");
  

Behavior

Each similarity measure is defined for one DataClass. For the computation of the similarity value only the information of the defined data class are allowed to use.

Author:
Rainer Maximini, tsauer
  • Field Details

  • Method Details

    • overwriteMatchingDataClasses

      void overwriteMatchingDataClasses(Model other)
      Checks for each measure if it contains a DataClass reference that is present in the given 'other' Model. If so, it replaces that reference.
      Parameters:
      other - The Model whose dataclasses should be referenced
    • addSimilarityMeasure

      void addSimilarityMeasure(SimilarityMeasure measure, String name) throws NameAlreadyExistsException
      Newly created SimilarityMeasures are not registered automatically. This must be done in this method whereby each SimilarityMeasure an unique name for this dataClass is defined. The corresponding DataClassis already defined in the similarity measure.
      Parameters:
      measure - the new similarity measure
      name - a new unique name
      Throws:
      NameAlreadyExistsException - is thrown if the given name is already defined for the data class.
    • createSimilarityMeasure

      SimilarityMeasure createSimilarityMeasure(String name, DataClass dataClass)
      Creates a new SimilarityMeasure  that is not automatically registered. The registration must be done with the addSimilarityMeasure(SimilarityMeasure, String) method.
      Parameters:
      name - Each similarity measure contains a static field "NAME" that contains the name of the similarity measure, e.g., SMAggregateAverage.NAME. If this field does not exist, the similarity measure cannot be instantiated.
      dataClass - The DataClass for that the similarity measure should be created.
      Returns:
      The new SimilarityMeasure  or null if the name does not relate to a similarity measure or the similarity measure does not fit to the data class
    • createAndRegisterSimilarityMeasure

      SimilarityMeasure createAndRegisterSimilarityMeasure(String uniqueName, String measureTemplateName, DataClass dataClass) throws NameAlreadyExistsException
      Creates a new SimilarityMeasure  and registers
      Parameters:
      uniqueName - a new unique name to identify the new measure
      measureTemplateName - Each similarity measure contains a static field "NAME" that contains the name of the similarity measure, e.g., SMAggregateAverage.NAME. If this field does not exists, the similarity measure can not be instantiated.
      dataClass - The DataClass for that the similarity measure should be created.
      Returns:
      The new SimilarityMeasure  or null if the name does not relate to a similarity * measure or the similarity measure does not fit to the data class
      Throws:
      NameAlreadyExistsException - is thrown if the given name is already defined for the data class.
    • registerSimilarityMeasureTemplate

      void registerSimilarityMeasureTemplate(SimilarityMeasure measure) throws NameAlreadyExistsException
      Registers a new SimilarityMeasure template with the similarity model. Call this method to register an an application-specific template. Afterwards, createSimilarityMeasure(String, DataClass) may be used to derive new instances from the template.
      Throws:
      NameAlreadyExistsException
    • getSimilarityMeasures

      List<SimilarityMeasure> getSimilarityMeasures()
      Returns:
      all available similarity measures also including system similarity measures
    • getSimilarityMeasure

      SimilarityMeasure getSimilarityMeasure(DataClass dataClass)
      Returns a suitable similarity measure for the given data class. Default measures are preferred over other suitable measures.
      Parameters:
      dataClass - The data class for that a suitable SimilarityMeasure should be retrieved.
      Returns:
      A SimilarityMeasure for the given data class.
    • getPossibleSimilarityMeasureFor

      String[] getPossibleSimilarityMeasureFor(DataClass dataClass)
      Computes all similarity measure that are possible for the given data class without any order.
      Parameters:
      dataClass - The data class for that the available SimilarityMeasures should be retrieved.
      Returns:
      An array of available SimilarityMeasure names for the given data class.
    • getPossibleSimilarityMeasureFor

      String[] getPossibleSimilarityMeasureFor(DataClass dataClass, String simName)
      Computes all similarity measure that are possible for the given data class / order combination. This does not includes similarity measures that are also possible without the order.
      Parameters:
      dataClass - The data class for that the available SimilarityMeasures should be retrieved.
      simName - The name of the similarity that should be used.
      Returns:
      An array of SimilarityMeasure names for the given data class and order.
    • getSimilarityMeasure

      SimilarityMeasure getSimilarityMeasure(DataClass dataClass, String simName)
      Parameters:
      dataClass - The data class for which the available SimilarityMeasures should be retrieved.
      simName - The name of the similarity that should be used.
      Returns:
      The specified SimilarityMeasure
    • getSimilarityMeasures

      SimilarityMeasure[] getSimilarityMeasures(DataClass dataClass)
      Retrieves all registered SimilarityMeasures for the given DataClass.
      Parameters:
      dataClass - The data class for that the registered SimilarityMeasures should be retrieved.
      Returns:
      An array of registered SimilarityMeasures for the given data class. If dataClass is null an empty array will be returned.
    • getSimilarityNamesFor

      String[] getSimilarityNamesFor(DataClass dataClass)
      Parameters:
      dataClass - The data class for that the registered SimilarityMeasure names should be retrieved.
      Returns:
      An array of names of the registered SimilarityMeasures for the given data class.
    • removeSimilarityMeasure

      SimilarityMeasure removeSimilarityMeasure(DataClass dataClass, String name)
      Removes the similarity measure with the given name for the given data class.
      Parameters:
      dataClass - The data class whos similarity measure should be removed.
      name - The name of the similarity measure that should be removed.
      Returns:
      The removed similarity measure or null if the measure was not found.
    • removeSimilarityMeasure

      SimilarityMeasure removeSimilarityMeasure(SimilarityMeasure measure)
      Removes the given similarity measure.
      Parameters:
      measure - The similarity measure that should be removed;
      Returns:
      The removed similarity measure or null if the measure was not found.
    • renameSimilarityMeasure

      SimilarityMeasure renameSimilarityMeasure(DataClass dataClass, String oldName, String newName) throws NameAlreadyExistsException, ProCAKENameNotFoundException
      Renames an already registered SimilarityMeasure. If the default SimilarityMeasure is effected, the default one will be renamed too.
      Parameters:
      dataClass - The data clas for that the similiarity measure should be renamed
      oldName - the old similarity measure name
      newName - the new similarity measure name
      Returns:
      the renamed similarity measure
      Throws:
      NameAlreadyExistsException - is thrown if the new name already exists for the data class
      ProCAKENameNotFoundException - is thrown if now similarity with the old name for the data class can be found.
    • setDefaultSimilarityMeasure

      void setDefaultSimilarityMeasure(DataClass dataClass, String measureName) throws ProCAKENameNotFoundException
      The Retriever uses in general the default SimilarityMeasure  that can be defined with this method. Therefore the data class and the similarity measure name must be defined.
      Parameters:
      dataClass - The DataClass for that the default SimilarityMeasure should be defined.
      measureName - The name of the SimilarityMeasure.
      Throws:
      ProCAKENameNotFoundException
    • isDefaultSimilarityMeasure

      boolean isDefaultSimilarityMeasure(SimilarityMeasure similarityMeasure)
      Parameters:
      similarityMeasure - The similarity measure
      Returns:
      Returns true, if given measure is defined as default.
    • addParameter

      void addParameter(String name, String value)
      Adds the given name and value to the similarity parameter list. If the name is already used, the previous value will be overwritten with the given value.
      Parameters:
      name - The name of the parameter
      value - The value of the parameter
    • removeParameter

      void removeParameter(String name)
      The parameter with the given name will be removed from the internal parameter-list
      Parameters:
      name -
    • getParameter

      String getParameter(String name)
      The value with the given parameter name will be returned.
      Parameters:
      name -
      Returns:
      The requested value
    • getAllParameters

      Map<String,String> getAllParameters()
      Returns a complete list of all parameters in the system. This is a copy of the internal map, so modifications to this map do not harm the internal map.
      Returns: