de.dfki.mycbr.core.similarity
Class TaxonomyFct

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

public class TaxonomyFct
extends SymbolFct

Similarity function for symbol descriptions. The allowed values are structured using a tree. The root is the symbol's description. The children are maintained using a hash map. For each node in the tree (represented by pairs) we save a SymbolAttribute or SymbolDesc respectively and a similarity value of the children

Author:
myCBR Team

Constructor Summary
TaxonomyFct(Project prj, SymbolDesc topSymbol, java.util.List<SymbolAttribute> values, java.lang.String name)
          Initializes this with a new taxonomy as internal data structure.
 
Method Summary
 void clone(AttributeDesc descNEW, boolean active)
          Creates a new function which is the same function as this but with a different description, namely descNEW.
 java.util.Collection<java.util.Map.Entry<TaxonomyNode,TaxonomyNode>> entrySet()
           
 TaxonomyConfig getCaseConfig()
           
 java.lang.Object getCommonAncestor(SymbolAttribute symbolAtt1, SymbolAttribute symbolAtt2)
          Returns the node of the taxonomy which represents the deepest ancestor of the given symbol attributes.
 java.lang.Object getParent(TaxonomyNode currentNode)
          Returns the parent of the given node.
 TaxonomyConfig getQueryConfig()
           
 Similarity getSimilarity(TaxonomyNode node)
           
 Taxonomy getTaxonomy()
          Gets the internal data structure of this function.
 TaxonomyNode getTopSymbol()
          Returns the top symbol of the underlying taxonomy.
 void setCaseConfig(TaxonomyConfig caseConfig)
           
 void setNodeSimilarity(TaxonomyNode att, Similarity sim)
           
 void setParent(TaxonomyNode symbol, TaxonomyNode newParent)
          Changes the parent of symbol to newParent.
 void setQueryConfig(TaxonomyConfig queryConfig)
           
 void update(java.util.Observable o, java.lang.Object arg)
          Updates the underlying symbol table when the taxonomy changes.
 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, setSimilarity, setSimilarity, setSimilarity, setSimilarity, 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

TaxonomyFct

public TaxonomyFct(Project prj,
                   SymbolDesc topSymbol,
                   java.util.List<SymbolAttribute> values,
                   java.lang.String name)
Initializes this with a new taxonomy as internal data structure.

Parameters:
topSymbol - the description to which this function belongs to
values - the allowed symbol for which similarity computations should be done
Method Detail

updateTable

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

Throws:
java.lang.Exception

setNodeSimilarity

public void setNodeSimilarity(TaxonomyNode att,
                              Similarity sim)

getTaxonomy

public Taxonomy getTaxonomy()
Gets the internal data structure of this function. All the values known to this function are located somewhere in the taxonomy and have similarities for their children associated.

Returns:
the taxonomy underlying this similarity function

setQueryConfig

public void setQueryConfig(TaxonomyConfig queryConfig)
                    throws java.lang.Exception
Parameters:
queryConfig - the queryConfig to set
Throws:
java.lang.Exception

getQueryConfig

public TaxonomyConfig getQueryConfig()
Returns:
the queryConfig

setCaseConfig

public void setCaseConfig(TaxonomyConfig caseConfig)
                   throws java.lang.Exception
Parameters:
caseConfig - the caseConfig to set
Throws:
java.lang.Exception

getCaseConfig

public TaxonomyConfig getCaseConfig()
Returns:
the caseConfig

setParent

public void setParent(TaxonomyNode symbol,
                      TaxonomyNode newParent)
Changes the parent of symbol to newParent.

Parameters:
symbol - the symbol to become a child of newParent
newParent - the new parent of symbol
Throws:
java.lang.Exception

getCommonAncestor

public java.lang.Object getCommonAncestor(SymbolAttribute symbolAtt1,
                                          SymbolAttribute symbolAtt2)
Returns the node of the taxonomy which represents the deepest ancestor of the given symbol attributes. A node of the taxonomy is represented by a pair of attribute (or description in case of root) and a similarity.

Parameters:
symbolAtt1 - first attribute
symbolAtt2 - second attribute
Returns:
the common ancestor of the given attributes which is located deepest in the taxonomy

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Updates the underlying symbol table when the taxonomy changes. Calls updateTable()

Specified by:
update in interface java.util.Observer
Overrides:
update in class SymbolFct

getParent

public java.lang.Object getParent(TaxonomyNode currentNode)
Returns the parent of the given node. Calls Taxonomy.getParent(TaxonomyNode)

Parameters:
currentNode - the node whose parent should be returned
Returns:
the parent of the given node

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

getTopSymbol

public TaxonomyNode getTopSymbol()
Returns the top symbol of the underlying taxonomy.

Returns:
top symbol of the underlying Taxonomy

getSimilarity

public Similarity getSimilarity(TaxonomyNode node)
Parameters:
node - the node
Returns:
the similarity of the given node

entrySet

public java.util.Collection<java.util.Map.Entry<TaxonomyNode,TaxonomyNode>> entrySet()
Returns:
a collection of parent and child mappings