de.folt.fuzzy
Class PartitionedFuzzyNodeTree<K,T>

java.lang.Object
  extended by java.util.Observable
      extended by de.folt.fuzzy.PartitionedFuzzyNodeTree<K,T>
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
StringPartitionedFuzzyNodeTree

public class PartitionedFuzzyNodeTree<K,T>
extends java.util.Observable
implements java.io.Serializable

This class implements a partitioned fuzzy node tree; the fuzzy node trees are partitioned into buckets where each bucket corresponds to the KEYSUm of the fuzzy node root. * The rationality behind this tree is to split up a fuzzy node into a tree consisting of several fuzzy node roots based on the key sum of the fuzzy node. * This helps to restrict the number of fuzzy nodes searched to a boundary around the key sum of a search fuzzy key. This may not be an appropriate strategy for all types of fuzzy searches!
For each KEYSUM a root node is generated. The search is then done on the root nodes LowerLimit < KEYSUM SearchNODE < UpperLimit, where the limits are computed based on the similarity supplied. int iDiff (the limit difference for upper and lower) = (iNGram * (100 - similarity) / 100))

  Structure:
  [0] [1] [2]           ....        [i] .... [n] (a hash table)
   |                                 |
   references the root fuzzy node    references the root fuzzy node 
   with key sum 0                    with key sum i
 
Pattern used: Composite

Author:
klemens
See Also:
Serialized Form

Constructor Summary
PartitionedFuzzyNodeTree()
           
 
Method Summary
 int countNodes()
          countNodes count all the nodes in the tree
 java.lang.String format()
          format return a formated partitioned fuzzy tree based on the fuzzy nodes
 FuzzyNodeTree<K,T> getFuzzyNodeTree(int i)
          getRoot returns a specific fuzzy Node tree
 int getIMaxIndex()
           
 int getNODESMATCHED()
           
 int getNODESPUSHED()
           
 int getNODESSEARCHED()
           
 java.util.Hashtable<java.lang.String,FuzzyNodeTree<K,T>> getRoots()
           
 boolean insertFuzzyNode(FuzzyNode<K,T> fuzzyNodeToAdd)
          insertFuzzyNode inserts a Fuzzy node into a partitioned fuzzy node tree;
 boolean removeValue(FuzzyNode<K,T> fuzzyCompareKey)
          removeValue removes a value from the value list of the values of the node based on a key.
 java.util.Vector<FuzzyNodeSearchResult<K,T>> search(FuzzyNode<K,T> fuzzyCompareKey, int similarity)
          search returns all a FuzzyNodeSearchResult of all matching FuzzyNodes
 
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

PartitionedFuzzyNodeTree

public PartitionedFuzzyNodeTree()
Method Detail

countNodes

public int countNodes()
countNodes count all the nodes in the tree

Returns:
the nodes in the tree

format

public java.lang.String format()
format return a formated partitioned fuzzy tree based on the fuzzy nodes

Returns:
formatted partitioned fuzzy tree as string

getFuzzyNodeTree

public FuzzyNodeTree<K,T> getFuzzyNodeTree(int i)
getRoot returns a specific fuzzy Node tree

Parameters:
i - the index of the FuzzyTree to return
Returns:
the ith fuzzy node tree corresponding to the KEYSUM of the fuzzy node of this tree

getIMaxIndex

public int getIMaxIndex()
Returns:
the iMaxIndex -highest KEYSUm currently in the partitioned Fuzzy Node Tree

getNODESMATCHED

public int getNODESMATCHED()
Returns:
the nODESMATCHED

getNODESPUSHED

public int getNODESPUSHED()
Returns:
the nODESPUSHED

getNODESSEARCHED

public int getNODESSEARCHED()
Returns:
the nODESSEARCHED

getRoots

public java.util.Hashtable<java.lang.String,FuzzyNodeTree<K,T>> getRoots()
Returns:
the roots

insertFuzzyNode

public boolean insertFuzzyNode(FuzzyNode<K,T> fuzzyNodeToAdd)
insertFuzzyNode inserts a Fuzzy node into a partitioned fuzzy node tree;

Parameters:
fuzzyNodeToAdd - fuzzy node to insert
Returns:
true for success, false for failure

removeValue

public boolean removeValue(FuzzyNode<K,T> fuzzyCompareKey)
removeValue removes a value from the value list of the values of the node based on a key. The values of the key are the objects to remove from the list

Parameters:
fuzzyCompareKey - the key containing the value to remove
Returns:
true when successfully removed, otherwise false

search

public java.util.Vector<FuzzyNodeSearchResult<K,T>> search(FuzzyNode<K,T> fuzzyCompareKey,
                                                           int similarity)
search returns all a FuzzyNodeSearchResult of all matching FuzzyNodes

Parameters:
fuzzyCompareKey - the fuzzy node to search for with similarity
similarity - the similarity to search for
Returns:
a vector of FuzzyNodeSearchResult