de.dfki.mycbr.core.similarity
Class OrderedSymbolFct

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

public class OrderedSymbolFct
extends SymbolFct
implements java.util.Observer

This function provides a linear order of the known symbol attributes for the given description. These symbol attributes are then compared using the internal similarity function on the indexes. Therefore, the internal similarity function is instance of IntegerSimilarityFunction.

Author:
myCBR Team

Constructor Summary
OrderedSymbolFct(Project prj, SymbolDesc desc, java.lang.String name)
          Initializes this with the given description.
 
Method Summary
 void addSymbol(SymbolAttribute att)
          Adds the given attribute to the list of ordered symbols.
 void clone(AttributeDesc descNEW, boolean active)
          Creates a new function which is the same function as this but with a different description, namely descNEW.
 int getDistanceLastFirst()
           
 IntegerFct getInternalFunction()
          Gets the internal similarity function.
 java.util.HashMap<SymbolAttribute,java.lang.Integer> getOrder()
           
 boolean isCyclic()
          Returns whether this function is cyclic or not.
 void removeSymbol(SymbolAttribute att)
          Removes the given attribute from the list of ordered symbols and updates the internal tabel
 void setCyclic(boolean cyclic)
          Specifies whether this function is cyclic or not.
 void setDistanceLastFirst(int distanceLastFirst)
           
 void setOrderIndexOf(java.lang.String att, int index)
          Sets the index of att used to linearly order the attributes to index.
 void setOrderIndexOf(SymbolAttribute att, int index)
          Sets the index of att used to linearly order the attributes to index.
 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 update(java.util.Observable o, java.lang.Object arg1)
           
 void updateTable()
          Updates the similarity for each attribute combination in the underlying table according to the similarity specified by the taxonomy
 
Methods inherited from class de.dfki.mycbr.core.similarity.SymbolFct
calculateSimilarity, calculateSimilarity, getDesc, getMultipleConfig, getName, getProject, isSymmetric, setMultipleConfig, setName, setSymmetric
 
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

OrderedSymbolFct

public OrderedSymbolFct(Project prj,
                        SymbolDesc desc,
                        java.lang.String name)
                 throws java.lang.Exception
Initializes this with the given description.

Parameters:
desc - the description of the attributes to which this function can be applied
Throws:
java.lang.Exception
Method Detail

updateTable

public void updateTable()
                 throws java.lang.Exception
Updates the similarity for each attribute combination in the underlying table according to the similarity specified by the taxonomy

Throws:
java.lang.Exception

update

public void update(java.util.Observable o,
                   java.lang.Object arg1)
Specified by:
update in interface java.util.Observer
Overrides:
update in class SymbolFct

getOrder

public java.util.HashMap<SymbolAttribute,java.lang.Integer> getOrder()

getInternalFunction

public IntegerFct getInternalFunction()
Gets the internal similarity function. For the similarity computations the values in internal table are relevant. It might be that they are inconsistent with the internal function. If there are changes made to the internal similarity function then this function gets informed via the observable pattern and updates the internal table in case that the flag keepTableConsistent is set. Else sets the flag consistent to false.

Returns:
internal similarity function

removeSymbol

public void removeSymbol(SymbolAttribute att)
Removes the given attribute from the list of ordered symbols and updates the internal tabel

Parameters:
att - the attribute to be removed

addSymbol

public void addSymbol(SymbolAttribute att)
Adds the given attribute to the list of ordered symbols. This symbols gets the order highestOrder + 10. If this attribute is already contained, does nothing. Adds this attribute to the internal table, too.

Parameters:
att - the attribute to be added

setOrderIndexOf

public void setOrderIndexOf(SymbolAttribute att,
                            int index)
                     throws java.lang.Exception
Sets the index of att used to linearly order the attributes to index.

Parameters:
att - the attribute whose index should be set
index - the index to set
Throws:
java.lang.Exception

setOrderIndexOf

public void setOrderIndexOf(java.lang.String att,
                            int index)
                     throws java.lang.Exception
Sets the index of att used to linearly order the attributes to index.

Parameters:
att - the attribute whose index should be set
index - the index to set
Throws:
java.lang.Exception

isCyclic

public boolean isCyclic()
Returns whether this function is cyclic or not.

Returns:
true if this function is cyclic, false otherwise.

setCyclic

public void setCyclic(boolean cyclic)
Specifies whether this function is cyclic or not.

Parameters:
cyclic - true if this function is cyclic, false otherwise.

setSimilarity

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

Overrides:
setSimilarity in class SymbolFct
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)
Description copied from class: SymbolFct
Sets the similarity of the given symbols to a Similarity.get object initialized with sim. Calls SymbolFct.setSimilarity(Attribute, Attribute, Similarity)

Overrides:
setSimilarity in class SymbolFct
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)
Description copied from class: SymbolFct
Sets the similarity the given symbols to sim. Calls SymbolFct.setSimilarity(Attribute, Attribute, Similarity)

Overrides:
setSimilarity in class SymbolFct
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)
Description copied from class: SymbolFct
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.

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

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
Overrides:
clone in class SymbolFct

setDistanceLastFirst

public void setDistanceLastFirst(int distanceLastFirst)
Parameters:
distanceLastFirst - the distanceLastFirst to set

getDistanceLastFirst

public int getDistanceLastFirst()
Returns:
the distanceLastFirst