de.fu_berlin.ties.classify.winnow
Class SharedWinnowStore

java.lang.Object
  extended by de.fu_berlin.ties.classify.winnow.WinnowStore
      extended by de.fu_berlin.ties.classify.winnow.SharedWinnowStore
All Implemented Interfaces:
XMLStorable, Pruner, RemoveCallback

public class SharedWinnowStore
extends WinnowStore

A WinnowStore implementation that is shared between multiple classifiers to allow more efficient access. Not that this class is not synchronized and requires class-wide (not only instance-wide synchronization) if instances of this type are to be used in different threads!

Version:
$Revision: 1.11 $, $Date: 2006/10/21 16:03:59 $, $Author: siefkes $
Author:
Christian Siefkes

Field Summary
 
Fields inherited from class de.fu_berlin.ties.classify.winnow.WinnowStore
ATTRIB_HASH, ATTRIB_IGNORE_IRRELEVANT, ATTRIB_INIT_WEIGHTS, ATTRIB_MAX_SIZE, ATTRIB_PRUNE_CANDIDATES, ATTRIB_PRUNE_NUMBER, ATTRIB_WEIGHTS, CONFIG_IGNORE_IRRELEVANT, CONFIG_SHARED_STORE, ELEMENT_FEATURE, ELEMENT_MAIN
 
Constructor Summary
SharedWinnowStore(Element element)
          Creates a new instance from an XML element, fulfilling the recommandation of the XMLStorable interface.
SharedWinnowStore(float initialWeight, boolean ignoreIrrelevant, TiesConfiguration config, String configSuffix)
          Creates a new instance.
SharedWinnowStore(float initialWeight, TiesConfiguration config, String configSuffix)
          Creates a new instance.
 
Method Summary
 void destroy()
          Destroys the store if it will never be used again. This shared implementation also deletes the list of registered instances so all shared instances will become unusable!
 float[] getWeights(Feature feature)
          Returns the weights of a feature.
 void putWeights(Feature feature, float[] weights)
          Stores new weights for a feature.
 void removed(Object key)
          Method to be called whenever a key has been removed from a map.
 Map.Entry[] sortForPruning(Map.Entry[] candidates)
          Sorts an array of map entries that are candidates for being pruned (deleted). The current implementation does not support this functionality, always throwing an UnsupportedOperationException instead.
protected  AdaptableLRUMap store()
          Allows raw access to the internal store.
 ObjectElement toElement()
          Stores all relevant fields of this object in an XML element for serialization.
 String toString()
          Returns a string representation of this object.
 
Methods inherited from class de.fu_berlin.ties.classify.winnow.WinnowStore
create, initStore, initStore, isIgnoringIrrelevant, isRelevant, maxSize, removeFromRelevantKeys, reset, setRelevant, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SharedWinnowStore

public SharedWinnowStore(float initialWeight,
                         TiesConfiguration config,
                         String configSuffix)
Creates a new instance.

Parameters:
initialWeight - the initial weight of each feature (currently not used)
config - used to configure this instance
configSuffix - optional suffix appended to the configuration keys when configuring this instance; might be null

SharedWinnowStore

public SharedWinnowStore(float initialWeight,
                         boolean ignoreIrrelevant,
                         TiesConfiguration config,
                         String configSuffix)
Creates a new instance.

Parameters:
initialWeight - The initial weight of each feature (currently not used)
ignoreIrrelevant - whether features within a certain range around the default weight are ignored during classification
config - used to configure this instance
configSuffix - optional suffix appended to the configuration keys when configuring this instance; might be null

SharedWinnowStore

public SharedWinnowStore(Element element)
                  throws IllegalArgumentException
Creates a new instance from an XML element, fulfilling the recommandation of the XMLStorable interface.

Parameters:
element - the XML element containing the serialized representation
Throws:
IllegalArgumentException - if deserialization fails due to errors in the provided XML element
Method Detail

destroy

public void destroy()
Destroys the store if it will never be used again. The default implementation delegates to WinnowStore.reset(), but subclasses can overwrite this behaviour if appropriate. This shared implementation also deletes the list of registered instances so all shared instances will become unusable!

Overrides:
destroy in class WinnowStore

getWeights

public float[] getWeights(Feature feature)
Returns the weights of a feature.

Specified by:
getWeights in class WinnowStore
Parameters:
feature - the feature to look up
Returns:
The weights of this feature

putWeights

public void putWeights(Feature feature,
                       float[] weights)
Stores new weights for a feature.

Specified by:
putWeights in class WinnowStore
Parameters:
feature - the feature to use
weights - The new weights of this feature

removed

public void removed(Object key)
Method to be called whenever a key has been removed from a map.

Parameters:
key - the key that has been removed

sortForPruning

public Map.Entry[] sortForPruning(Map.Entry[] candidates)
Sorts an array of map entries that are candidates for being pruned (deleted). The current implementation does not support this functionality, always throwing an UnsupportedOperationException instead. Use DefaultWinnowStore instead if you want support for pruning of multiple candidates.

Parameters:
candidates - an array of entries to be considered as candidates for pruning
Returns:
a resorted array of the entries, sorted by prunability so the entries that should be preferably pruned come first

store

protected AdaptableLRUMap store()
Allows raw access to the internal store. Used by the WinnowStore.maxSize(), WinnowStore.size() and WinnowStore.reset() methods.

Specified by:
store in class WinnowStore
Returns:
the value of the attribute

toElement

public ObjectElement toElement()
Stores all relevant fields of this object in an XML element for serialization. An equivalent object can be created by calling ObjectElement.createObject(org.dom4j.Element, Class) on the created element.

Returns:
the created XML element

toString

public String toString()
Returns a string representation of this object.

Overrides:
toString in class Object
Returns:
a textual representation


Copyright © 2003-2007 Christian Siefkes. All Rights Reserved.