de.fu_berlin.ties.context
Class LocalFeature

java.lang.Object
  extended by de.fu_berlin.ties.classify.feature.Feature
      extended by de.fu_berlin.ties.context.LocalFeature

public class LocalFeature
extends Feature

An immutable representation of the local part of a feature, useful to cache and re-use the parts of feature representation that do not depend on the relative position of the element to classify. Must be wrapped in a GlobalFeature for classification.

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

Field Summary
protected static char CLOSE
          Character closing a quoted value.
protected static LocalFeature MARKER_START
          Constant for a marker feature that marks the start of an axis.
protected static char OPEN
          Character opening a quoted value.
 
Constructor Summary
protected LocalFeature(String element, FeatureType myType, String myName, String myValue, String myComment)
          Non-public constructor.
 
Method Summary
static List<LocalFeature> createAttributeFeatures(String element, String attributeName, String featureValue, int splitMaximum)
          Factory method creating a feature that wraps an attribute value.
static LocalFeature createCalculatedFeature(String element, String calcName, String featureValue)
          Factory method creating a feature that wraps a calculated value.
static List<LocalFeature> createCalculatedFeatures(String element, String calcName, String featureValue, int splitMaximum)
          Factory method creating a feature that wraps a calculated value that might contain whitespace.
static LocalFeature createElementFeature(String element)
          Factory method creating a feature that just represents an element itself.
static List<LocalFeature> createTextFeatures(String element, String featureValue, int splitMaximum)
          Factory method creating a feature that wraps textual content of an element.
 String getElementName()
          Returns the name of the element this feature is attached to.
 String getName()
          Returns the name of this feature.
 String getRepresentation()
          Returns the representation of this feature, to be used for classification.
 FeatureType getType()
          Returns the type of this feature.
 String getValue()
          Returns the value wrapped by this feature.
static String quote(String text)
          Quotes a value text (by enclosing it between OPEN and CLOSE character).
 String toString()
          Returns a string representation of this object.
 
Methods inherited from class de.fu_berlin.ties.classify.feature.Feature
compactRepresentation, equals, getComment, getFullRepresentation, getFullRepresentation, getUserData, hashCode, setUserData
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MARKER_START

protected static final LocalFeature MARKER_START
Constant for a marker feature that marks the start of an axis.


OPEN

protected static final char OPEN
Character opening a quoted value.

See Also:
Constant Field Values

CLOSE

protected static final char CLOSE
Character closing a quoted value.

See Also:
Constant Field Values
Constructor Detail

LocalFeature

protected LocalFeature(String element,
                       FeatureType myType,
                       String myName,
                       String myValue,
                       String myComment)
Non-public constructor. Use the factory methods to create new instances; or use one of the predefined marker constants.

Parameters:
element - the name of the element this feature is attached to (should be empty for marker features)
myType - the type of this feature
myName - the name of this feature (should be empty for textual or element features)
myValue - the value wrapped by this feature (might be null for marker or element features)
myComment - a comment on this feature, ignored for classification; might be null
Method Detail

createAttributeFeatures

public static List<LocalFeature> createAttributeFeatures(String element,
                                                         String attributeName,
                                                         String featureValue,
                                                         int splitMaximum)
                                                  throws IllegalArgumentException
Factory method creating a feature that wraps an attribute value. It the featureValue contains whitespace, it is split and up to splitMaximum different features are created for the subsequences (discarding initial surplus sequences, if any).

Parameters:
element - the name of the element this feature is attached to
attributeName - the name of the attribute; must not be empty
featureValue - the textual content to wrap
splitMaximum - the maximum number of features to generate
Returns:
a list of created feature
Throws:
IllegalArgumentException - if the specified attribute name is empty (and thus not a valid name)

createCalculatedFeature

public static LocalFeature createCalculatedFeature(String element,
                                                   String calcName,
                                                   String featureValue)
Factory method creating a feature that wraps a calculated value.

Parameters:
element - the name of the element this feature is attached to
calcName - the name identifying the calculated value
featureValue - the calculated value to wrap; should not contain whitespace (otherwise the classifier will get confesed)
Returns:
the created feature

createCalculatedFeatures

public static List<LocalFeature> createCalculatedFeatures(String element,
                                                          String calcName,
                                                          String featureValue,
                                                          int splitMaximum)
                                                   throws IllegalArgumentException
Factory method creating a feature that wraps a calculated value that might contain whitespace. It the featureValue contains whitespace, it is split and up to splitMaximum different features are created for the subsequences (discarding initial surplus sequences, if any).

Parameters:
element - the name of the element this feature is attached to
calcName - the name identifying the calculated value
featureValue - the textual content to wrap
splitMaximum - the maximum number of features to generate
Returns:
a list of created features
Throws:
IllegalArgumentException - if the specified calcName is empty (and thus not a valid name)

createElementFeature

public static LocalFeature createElementFeature(String element)
Factory method creating a feature that just represents an element itself.

Parameters:
element - the name of the element this feature is attached to
Returns:
the created feature

createTextFeatures

public static List<LocalFeature> createTextFeatures(String element,
                                                    String featureValue,
                                                    int splitMaximum)
Factory method creating a feature that wraps textual content of an element. It the featureValue contains whitespace, it is split and up to splitMaximum different features are created for the subsequences (discarding initial surplus sequences, if any).

Parameters:
element - the name of the element this feature is attached to
featureValue - the textual content to wrap
splitMaximum - the maximum number of features to generate
Returns:
a list of created feature

quote

public static String quote(String text)
Quotes a value text (by enclosing it between OPEN and CLOSE character).

Parameters:
text - the text to quote (might be null)
Returns:
the quoted value, or the empty string if text is null

getElementName

public String getElementName()
Returns the name of the element this feature is attached to.

Returns:
the name of the element

getName

public String getName()
Returns the name of this feature.

Returns:
the name of this feature (the empty string if this is a textual feature)

getRepresentation

public String getRepresentation()
Returns the representation of this feature, to be used for classification.

Specified by:
getRepresentation in class Feature
Returns:
the feature representation, or null if this feature contains only a comment

getType

public FeatureType getType()
Returns the type of this feature.

Returns:
the type

getValue

public String getValue()
Returns the value wrapped by this feature.

Returns:
the value

toString

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

Overrides:
toString in class Feature
Returns:
a textual representation combining all relevant fields


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