de.dfki.mycbr.core.similarity
Class SymbolFct

java.lang.Object
  extended by java.util.Observable
      extended by de.dfki.mycbr.core.similarity.SymbolFct
All Implemented Interfaces:
ISimFct, java.util.Observer
Direct Known Subclasses:
OrderedSymbolFct, SpecialFct, TaxonomyFct

public class SymbolFct
extends java.util.Observable
implements ISimFct

Holds the similarity of the known attributes for the given description in a two dimensional array (table). The indexes of the attributes in this table are maintained by the corresponding range (given by the description). If this function is symmetric, the table should be symmetric, too.

Author:
myCBR Team

Constructor Summary
SymbolFct(Project prj, SymbolDesc desc, java.lang.String name)
          Initializes this by asking the given description for the number of allowed symbols.
SymbolFct(SymbolFct f)
          Initializes this by transforming the given symbol function into a similarity table.
 
Method Summary
 Similarity calculateSimilarity(Attribute attribute, Attribute attribute2)
          Returns the similarity of the given attributes.
 Similarity calculateSimilarity(java.lang.String value1, java.lang.String value2)
          Returns the similarity of the given attributes.
 void clone(AttributeDesc descNEW, boolean active)
          Creates a new function which is the same function as this but with a different description, namely descNEW.
 SymbolDesc getDesc()
          Gets the symbol description of the attributes this function is defined on
 MultipleConfig getMultipleConfig()
           
 java.lang.String getName()
          Returns the name of this function
 Project getProject()
           
 boolean isSymmetric()
          Specifies whether this function is symmetric or asymmetric
 void setMultipleConfig(MultipleConfig mc)
           
 void setName(java.lang.String name)
          Sets the name of this function to name
 boolean setSimilarity(Attribute att1, Attribute att2, Similarity sim)
          Sets the similarity of att1 and att2 to sim.
 boolean setSimilarity(java.lang.String symbol1, java.lang.String symbol2, double sim)
          Sets the similarity of the given symbols to a Similarity.get object initialized with sim.
 boolean setSimilarity(java.lang.String symbol1, java.lang.String symbol2, Similarity sim)
          Sets the similarity the given symbols to sim.
 boolean setSimilarity(SymbolAttribute att1, SymbolAttribute att2, double sim)
          Sets the similarity of att1 and att2 to a Similarity.get object initialized with sim.
 void setSymmetric(boolean symmetric)
          Specifies whether this function is symmetric or not.
 void update(java.util.Observable o, java.lang.Object arg)
           
 
Methods inherited from class java.util.Observable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SymbolFct

public SymbolFct(Project prj,
                 SymbolDesc desc,
                 java.lang.String name)
Initializes this by asking the given description for the number of allowed symbols. This number determines the size of the underlying table. Calls initTable() to fill the table with default values.

Parameters:
desc - the description of the given symbol attributes

SymbolFct

public SymbolFct(SymbolFct f)
Initializes this by transforming the given symbol function into a similarity table. To change f by this function you have to call SimpleAttDesc.deleteSimFct(ISimFct) and then SimpleAttDesc.addFct(ISimFct)

Parameters:
f - any symbol function
Method Detail

calculateSimilarity

public Similarity calculateSimilarity(Attribute attribute,
                                      Attribute attribute2)
Returns the similarity of the given attributes. Returns null if the attributes do not have the same description, if they are not of type SymbolAttribute or SpecialValueAttribute, or if there is something wrong with the index structure provided by the given range.

Specified by:
calculateSimilarity in interface ISimFct
Parameters:
attribute - first attribute
attribute2 - second attribute
Returns:
similarity of the given attributes, invalid similarity if an error occurs
Throws:
java.lang.Exception

calculateSimilarity

public Similarity calculateSimilarity(java.lang.String value1,
                                      java.lang.String value2)
                               throws java.lang.Exception
Returns the similarity of the given attributes. Returns null if the attributes do not have the same description, if they are not of type SymbolAttribute or SpecialValueAttribute, or if there is something wrong with the index structure provided by the given range.

Parameters:
value1 - first attribute
value2 - second attribute
Returns:
similarity of the given attributes, invalid similarity if an error occurs
Throws:
java.lang.Exception

setSimilarity

public boolean setSimilarity(SymbolAttribute att1,
                             SymbolAttribute att2,
                             double sim)
Sets the similarity of att1 and att2 to a Similarity.get object initialized with sim. Calls setSimilarity(Attribute, Attribute, Similarity)

Parameters:
att1 - the first attribute
att2 - the second attribute
sim - the Similarity.get
Returns:
true, if the similarity has been updated successfully, false otherwise

setSimilarity

public boolean setSimilarity(java.lang.String symbol1,
                             java.lang.String symbol2,
                             double sim)
Sets the similarity of the given symbols to a Similarity.get object initialized with sim. Calls setSimilarity(Attribute, Attribute, Similarity)

Parameters:
symbol1 - the first attribute's value
symbol2 - the second attribute's value
sim - the Similarity.get
Returns:
true, if the similarity has been updated successfully, false otherwise

setSimilarity

public boolean setSimilarity(java.lang.String symbol1,
                             java.lang.String symbol2,
                             Similarity sim)
Sets the similarity the given symbols to sim. Calls setSimilarity(Attribute, Attribute, Similarity)

Parameters:
symbol1 - the first attribute's value
symbol2 - the second attribute's value
sim - the Similarity.get
Returns:
true, if the similarity has been updated successfully, false otherwise

setSimilarity

public boolean setSimilarity(Attribute att1,
                             Attribute att2,
                             Similarity sim)
Sets the similarity of att1 and att2 to sim. If this function is symmetric also sets the similarity of att2 and att1 to sim. Returns true if the similarity has been successfully updated, false if there is something wrong with the index structure provided by the given range or if the attributes are not contained in this range.

Parameters:
att1 - the first attribute
att2 - the second attribute
sim - the Similarity.get
Returns:
true, if the similarity has been updated successfully, false otherwise

isSymmetric

public boolean isSymmetric()
Description copied from interface: ISimFct
Specifies whether this function is symmetric or asymmetric

Specified by:
isSymmetric in interface ISimFct
Returns:
true, if similarity function is symmetric, false otherwise

setSymmetric

public void setSymmetric(boolean symmetric)
Specifies whether this function is symmetric or not.

Specified by:
setSymmetric in interface ISimFct
Parameters:
symmetric - true, if this function is symmetric, false otherwise

getDesc

public SymbolDesc getDesc()
Gets the symbol description of the attributes this function is defined on

Specified by:
getDesc in interface ISimFct
Returns:
symbol description of the given attributes

getName

public java.lang.String getName()
Description copied from interface: ISimFct
Returns the name of this function

Specified by:
getName in interface ISimFct
Returns:
the name of this function

setName

public void setName(java.lang.String name)
Description copied from interface: ISimFct
Sets the name of this function to name

Specified by:
setName in interface ISimFct
Parameters:
name - the new name of this function

getProject

public Project getProject()
Specified by:
getProject in interface ISimFct

getMultipleConfig

public MultipleConfig getMultipleConfig()
Specified by:
getMultipleConfig in interface ISimFct

setMultipleConfig

public void setMultipleConfig(MultipleConfig mc)
Specified by:
setMultipleConfig in interface ISimFct

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Specified by:
update in interface java.util.Observer

clone

public void clone(AttributeDesc descNEW,
                  boolean active)
Description copied from interface: ISimFct
Creates a new function which is the same function as this but with a different description, namely descNEW. Assumption: this function fits the description of descNEW.

Specified by:
clone in interface ISimFct