de.fu_berlin.ties.classify.feature
Class FeatureTransformer

java.lang.Object
  extended by de.fu_berlin.ties.classify.feature.FeatureTransformer
All Implemented Interfaces:
XMLStorable
Direct Known Subclasses:
OSBTransformer, SBPHTransformer

public abstract class FeatureTransformer
extends Object
implements XMLStorable

A feature transformer transforms a feature vector in a suitable way. Feature transformer can be used for feature selection (discarding irrelevant features), for combining features etc. Feature transformers can be chained -- in this case each feature transformer will work on the featured returned by the previous one.

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

Field Summary
static String CONFIG_TRANSFORMERS
          Configuration key specifying the list of transformers to chain.
static QName ELEMENT_MAIN
          Name of the main element used for XML serialization.
 
Constructor Summary
FeatureTransformer(Element element)
          Creates a new instance from an XML element, fulfilling the recommandation of the XMLStorable interface.
FeatureTransformer(FeatureTransformer precTrans)
          Creates a new instance.
 
Method Summary
static FeatureTransformer createTransformer()
          Factory method that delegates to createTransformer() using the standard configuration.
static FeatureTransformer createTransformer(TiesConfiguration config)
          Factory method that creates a feature transformer based on the CONFIG_TRANSFORMERS key in the provided configuration.
protected abstract  FeatureVector doTransform(FeatureVector orgFeatures)
          Transforms a feature vector.
 FeatureTransformer getPrecedingTransformer()
          Returns the preceding transformer used if this transformer is part of a chain.
 ObjectElement toElement()
          Stores all relevant fields of this object in an XML element for serialization.
 String toString()
          Returns a string representation of this object.
 FeatureVector transform(FeatureVector orgFeatures)
          Transforms a feature vector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ELEMENT_MAIN

public static final QName ELEMENT_MAIN
Name of the main element used for XML serialization.


CONFIG_TRANSFORMERS

public static final String CONFIG_TRANSFORMERS
Configuration key specifying the list of transformers to chain.

See Also:
Constant Field Values
Constructor Detail

FeatureTransformer

public FeatureTransformer(FeatureTransformer precTrans)
Creates a new instance.

Parameters:
precTrans - the preceding transformer to use if this transformer is part of a chain; null otherwise

FeatureTransformer

public FeatureTransformer(Element element)
                   throws InstantiationException
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:
InstantiationException - if the given element does not contain a valid transformer description
Method Detail

createTransformer

public static FeatureTransformer createTransformer()
                                            throws IllegalArgumentException,
                                                   ProcessingException
Factory method that delegates to createTransformer() using the standard configuration.

Returns:
the last transformer in the created transformer chain; or null is no transformers are specified (parameter value is null or empty)
Throws:
IllegalArgumentException - if the value of the CONFIG_TRANSFORMERS key is invalid
ProcessingException - if an error occurred while creating the transformer

createTransformer

public static FeatureTransformer createTransformer(TiesConfiguration config)
                                            throws IllegalArgumentException,
                                                   ProcessingException
Factory method that creates a feature transformer based on the CONFIG_TRANSFORMERS key in the provided configuration. This parameter must contain a list fully specified names of subclasses of this class) used in a chain.

Eeach specified transformer must provide a constructor accepting a preceding FeatureTransformer as first argument and a TiesConfiguration as second argument.

Parameters:
config - the configuration to use
Returns:
the last transformer in the created transformer chain; or null is no transformers are specified (parameter value is null or empty)
Throws:
IllegalArgumentException - if the value of the CONFIG_TRANSFORMERS key is invalid
ProcessingException - if an error occurred while creating the transformer

doTransform

protected abstract FeatureVector doTransform(FeatureVector orgFeatures)
Transforms a feature vector.

Parameters:
orgFeatures - the original feature vector to transform
Returns:
a new feature vector containing the transformed features

getPrecedingTransformer

public FeatureTransformer getPrecedingTransformer()
Returns the preceding transformer used if this transformer is part of a chain.

Returns:
the preceding transformer, if any; or null if this transformer is not part of a chain resp. is the first transformer in a chain

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.

Specified by:
toElement in interface XMLStorable
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

transform

public FeatureVector transform(FeatureVector orgFeatures)
Transforms a feature vector. This method calls itself on the preceding transformer (if any) prior to delegating to the abstract doTransform(FeatureVector) method.

Parameters:
orgFeatures - the original feature vector to transform
Returns:
a new feature vector containing the transformed features


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