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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addParameter
(String name, String value) Adds the given name and value to the similarity parameter list.void
addSimilarityMeasure
(SimilarityMeasure measure, String name) Newly createdSimilarityMeasure
s are not registered automatically.createAndRegisterSimilarityMeasure
(String uniqueName, String measureTemplateName, DataClass dataClass) Creates a newSimilarityMeasure
and registerscreateSimilarityMeasure
(String name, DataClass dataClass) Creates a newSimilarityMeasure
that is not automatically registered.Returns a complete list of all parameters in the system.getParameter
(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.getSimilarityMeasure
(DataClass dataClass) Returns a suitable similarity measure for the given data class.getSimilarityMeasure
(DataClass dataClass, String simName) getSimilarityMeasures
(DataClass dataClass) Retrieves all registeredSimilarityMeasure
s for the givenDataClass
.String[]
getSimilarityNamesFor
(DataClass dataClass) boolean
isDefaultSimilarityMeasure
(SimilarityMeasure similarityMeasure) void
Checks for each measure if it contains aDataClass
reference that is present in the given 'other' Model.void
Registers a newSimilarityMeasure
template with the similarity model.void
removeParameter
(String name) The parameter with the given name will be removed from the internal parameter-listremoveSimilarityMeasure
(DataClass dataClass, String name) Removes the similarity measure with the given name for the given data class.removeSimilarityMeasure
(SimilarityMeasure measure) Removes the given similarity measure.renameSimilarityMeasure
(DataClass dataClass, String oldName, String newName) Renames an already registeredSimilarityMeasure
.void
setDefaultSimilarityMeasure
(DataClass dataClass, String measureName) TheRetriever
uses in general the defaultSimilarityMeasure
that can be defined with this method.
-
Field Details
-
COMPONENT
- See Also:
-
LOG_CREATING_NEW_MEASURE_FAILED
- See Also:
-
LOG_NO_MODEL_READER_FOUND
- See Also:
-
LOG_READING_INITIAL_MODEL_FAILED
- See Also:
-
LOG_SIMILARITY_NAME_ALREADY_EXISTS
- See Also:
-
LOG_SIMILARITY_NAME_NOT_FOUND
- See Also:
-
-
Method Details
-
overwriteMatchingDataClasses
Checks for each measure if it contains aDataClass
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
Newly createdSimilarityMeasure
s are not registered automatically. This must be done in this method whereby eachSimilarityMeasure
an unique name for this dataClass is defined. The correspondingDataClass
is 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
Creates a newSimilarityMeasure
that 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 exist, the similarity measure cannot be instantiated.dataClass
- TheDataClass
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 newSimilarityMeasure
and 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
- TheDataClass
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
Registers a newSimilarityMeasure
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
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 suitableSimilarityMeasure
should be retrieved.- Returns:
- A
SimilarityMeasure
for the given data class.
-
getPossibleSimilarityMeasureFor
Computes all similarity measure that are possible for the given data class without any order.- Parameters:
dataClass
- The data class for that the availableSimilarityMeasure
s should be retrieved.- Returns:
- An array of available
SimilarityMeasure
names for the given data class.
-
getPossibleSimilarityMeasureFor
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 availableSimilarityMeasure
s 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
- Parameters:
dataClass
- The data class for which the availableSimilarityMeasure
s should be retrieved.simName
- The name of the similarity that should be used.- Returns:
- The specified
SimilarityMeasure
-
getSimilarityMeasures
Retrieves all registeredSimilarityMeasure
s for the givenDataClass
.- Parameters:
dataClass
- The data class for that the registeredSimilarityMeasure
s should be retrieved.- Returns:
- An array of registered
SimilarityMeasure
s for the given data class. IfdataClass
isnull
an empty array will be returned.
-
getSimilarityNamesFor
- Parameters:
dataClass
- The data class for that the registeredSimilarityMeasure
names should be retrieved.- Returns:
- An array of names of the registered
SimilarityMeasure
s for the given data class.
-
removeSimilarityMeasure
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
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 registeredSimilarityMeasure
. If the defaultSimilarityMeasure
is 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 classProCAKENameNotFoundException
- 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 TheRetriever
uses in general the defaultSimilarityMeasure
that can be defined with this method. Therefore the data class and the similarity measure name must be defined.- Parameters:
dataClass
- TheDataClass
for that the defaultSimilarityMeasure
should be defined.measureName
- The name of theSimilarityMeasure
.- Throws:
ProCAKENameNotFoundException
-
isDefaultSimilarityMeasure
- Parameters:
similarityMeasure
- The similarity measure- Returns:
- Returns true, if given measure is defined as default.
-
addParameter
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
The parameter with the given name will be removed from the internal parameter-list- Parameters:
name
-
-
getParameter
The value with the given parameter name will be returned.- Parameters:
name
-- Returns:
- The requested value
-
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:
-