Interface SimilarityModel
-
- All Known Implementing Classes:
SimilarityModelImpl
public interface SimilarityModelData Similarity Model
The similarity model contains for each
DataClassa set of similarity measures. EachSimilarityMeasuremust have a unique name for oneDataClass. TheRetrieveruses, if not defined otherwise, the defaultSimilarityMeasure. The default similarity measure can be defined with the methodsetDefaultSimilarityMeasure(DataClass, String).Creating a new similarity measure
To assign a new
SimilarityMeasureto aDataClassobject it must be first created withcreateSimilarityMeasure(String, DataClass)and than added to the similarity model withaddSimilarityMeasure(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 Summary
Fields Modifier and Type Field Description static StringCOMPONENTComponent: "cake.data.similarity" (LogComponentIdentifier.COMPONENT)static StringCOMPONENT_KEYComponent-Key: "00" (LogComponentIdentifier.COMPONENT_KEY_SIMILARITYMODEL)static StringLOG_CREATING_NEW_MEASURE_FAILEDCreation of a new measure failed.static StringLOG_INITIALIZATION_FAILEDInitialization of system-similarity-measures failed.static StringLOG_NO_MODEL_READER_FOUNDNo similarity-model-reader found.static StringLOG_READING_INITIAL_MODEL_FAILEDReading of initial similarity model failed.static StringLOG_SIMILARITY_NAME_ALREADY_EXISTSA similarity with this name already exists for the specified class in the current model.static StringLOG_SIMILARITY_NAME_NOT_FOUNDA measure with the specified name could not be found for the specified class in the current model.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddParameter(String name, String value)Adds the given name and value to the similarity parameter list.voidaddSimilarityMeasure(SimilarityMeasure measure, String name)Newly createdSimilarityMeasures are not registered automatically.SimilarityMeasurecreateAndRegisterSimilarityMeasure(String uniqueName, String measureTemplateName, DataClass dataClass)Creates a newSimilarityMeasureand registersSimilarityMeasurecreateSimilarityMeasure(String name, DataClass dataClass)Creates a newSimilarityMeasurethat is not automatically registered.Map<String,String>getAllParameters()Returns a complete list of all parameters in the system.StringgetParameter(String name)The value with the given parameter name will be returned.String[]getPossibleSimilarityMeasureFor(DataClass dataClass)Computes all similarity measure that are possible for the given data class without any order.String[]getPossibleSimilarityMeasureFor(DataClass dataClass, String simName)Computes all similarity measure that are possible for the given data class / order combination.SimilarityMeasuregetSimilarityMeasure(DataClass dataClass)Returns a suitable similarity measure for the given data class.SimilarityMeasuregetSimilarityMeasure(DataClass dataClass, String simName)List<SimilarityMeasure>getSimilarityMeasures()SimilarityMeasure[]getSimilarityMeasures(DataClass dataClass)Retrieves all registeredSimilarityMeasures for the givenDataClass.String[]getSimilarityNamesFor(DataClass dataClass)booleanisDefaultSimilarityMeasure(SimilarityMeasure similarityMeasure)voidoverwriteMatchingDataClasses(Model other)Checks for each measure if it contains aDataClassreference that is present in the given 'other' Model.voidregisterSimilarityMeasureTemplate(SimilarityMeasure measure)Registers a newSimilarityMeasuretemplate with the similarity model.voidremoveParameter(String name)The parameter with the given name will be removed from the internal parameter-listSimilarityMeasureremoveSimilarityMeasure(DataClass dataClass, String name)Removes the similarity measure with the given name for the given data class.SimilarityMeasureremoveSimilarityMeasure(SimilarityMeasure measure)Removes the given similarity measure.SimilarityMeasurerenameSimilarityMeasure(DataClass dataClass, String oldName, String newName)Renames an already registeredSimilarityMeasure.voidsetDefaultSimilarityMeasure(DataClass dataClass, String measureName)TheRetrieveruses in general the defaultSimilarityMeasurethat can be defined with this method.
-
-
-
Field Detail
-
COMPONENT
static final String COMPONENT
Component: "cake.data.similarity" (LogComponentIdentifier.COMPONENT)- See Also:
- Constant Field Values
-
COMPONENT_KEY
static final String COMPONENT_KEY
Component-Key: "00" (LogComponentIdentifier.COMPONENT_KEY_SIMILARITYMODEL)- See Also:
- Constant Field Values
-
LOG_CREATING_NEW_MEASURE_FAILED
static final String LOG_CREATING_NEW_MEASURE_FAILED
Creation of a new measure failed.- Component:
COMPONENT - Key: "0002"
- this
- Similarityname
- See Also:
- Constant Field Values
- Component:
-
LOG_INITIALIZATION_FAILED
static final String LOG_INITIALIZATION_FAILED
Initialization of system-similarity-measures failed.- Component:
COMPONENT - Key: "0005"
- this
- Reason
- See Also:
- Constant Field Values
- Component:
-
LOG_NO_MODEL_READER_FOUND
static final String LOG_NO_MODEL_READER_FOUND
No similarity-model-reader found.- Component:
COMPONENT - Key: "0000"
- this
- See Also:
- Constant Field Values
- Component:
-
LOG_READING_INITIAL_MODEL_FAILED
static final String LOG_READING_INITIAL_MODEL_FAILED
Reading of initial similarity model failed.- Component:
COMPONENT - Key: "0001"
- this
- See Also:
- Constant Field Values
- Component:
-
LOG_SIMILARITY_NAME_ALREADY_EXISTS
static final String LOG_SIMILARITY_NAME_ALREADY_EXISTS
A similarity with this name already exists for the specified class in the current model.- See Also:
- Constant Field Values
-
LOG_SIMILARITY_NAME_NOT_FOUND
static final String LOG_SIMILARITY_NAME_NOT_FOUND
A measure with the specified name could not be found for the specified class in the current model.- See Also:
- Constant Field Values
-
-
Method Detail
-
overwriteMatchingDataClasses
void overwriteMatchingDataClasses(Model other)
Checks for each measure if it contains aDataClassreference 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 createdSimilarityMeasures are not registered automatically. This must be done in this method whereby eachSimilarityMeasurean unique name for this dataClass is defined. The correspondingDataClassis already defined in the similarity measure.- Parameters:
measure- the new similarity measurename- 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 newSimilarityMeasurethat is not automatically registered. The registration must be done with theaddSimilarityMeasure(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 exists, the similarity measure can not be instantiated.dataClass- TheDataClassfor that the similarity measure should be created.- Returns:
- The new
SimilarityMeasureor 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 newSimilarityMeasureand registers- Parameters:
uniqueName- a new unique name to identify the new measuremeasureTemplateName- 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- TheDataClassfor that the similarity measure should be created.- Returns:
- The new
SimilarityMeasureor 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 newSimilarityMeasuretemplate 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 suitableSimilarityMeasureshould be retrieved.- Returns:
- A
SimilarityMeasurefor 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 availableSimilarityMeasures should be retrieved.- Returns:
- An array of available
SimilarityMeasurenames 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 availableSimilarityMeasures 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 availableSimilarityMeasures should be retrieved.simName- The name of the similarity that should be used.- Returns:
- The specified
SimilarityMeasure
-
getSimilarityMeasures
SimilarityMeasure[] getSimilarityMeasures(DataClass dataClass)
Retrieves all registeredSimilarityMeasures for the givenDataClass.- Parameters:
dataClass- The data class for that the registeredSimilarityMeasures should be retrieved.- Returns:
- An array of registered
SimilarityMeasures for the given data class. IfdataClassisnullan empty array will be returned.
-
getSimilarityNamesFor
String[] getSimilarityNamesFor(DataClass dataClass)
- Parameters:
dataClass- The data class for that the registeredSimilarityMeasurenames 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, NameNotFoundException
Renames an already registeredSimilarityMeasure. If the defaultSimilarityMeasureis effected, the default one will be renamed too.- Parameters:
dataClass- The data clas for that the similiarity measure should be renamedoldName- the old similarity measure namenewName- the new similarity measure name- Returns:
- the renamed similarity measure
- Throws:
NameAlreadyExistsException- is thrown if the new name already exists for the data classNameNotFoundException- is thrown if now similarity with the old name for the data class can be found.
-
setDefaultSimilarityMeasure
void setDefaultSimilarityMeasure(DataClass dataClass, String measureName) throws NameNotFoundException
TheRetrieveruses in general the defaultSimilarityMeasurethat can be defined with this method. Therefore the data class and the similarity measure name must be defined.- Parameters:
dataClass- TheDataClassfor that the defaultSimilarityMeasureshould be defined.measureName- The name of theSimilarityMeasure.- Throws:
NameNotFoundException
-
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 parametervalue- 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
-
-