de.fu_berlin.ties.classify.feature
Class Feature

java.lang.Object
  extended by de.fu_berlin.ties.classify.feature.Feature
Direct Known Subclasses:
DefaultFeature, GlobalFeature, LocalFeature

public abstract class Feature
extends Object

An abstract base class for immutable feature representation used for classification.

Version:
$Revision: 1.2 $, $Date: 2004/05/31 19:13:49 $, $Author: siefkes $
Author:
Christian Siefkes

Constructor Summary
Feature()
          Creates a new instance, without storing a comment.
Feature(String myComment)
          Creates a new instance.
 
Method Summary
 boolean equals(Object obj)
          Indicates whether some other object is "equal to" this one, fulfulling the Object.equals(java.lang.Object) contract.
 String getComment()
          Returns the comment attached to this feature, if any.
 String getFullRepresentation()
          Prints a full representation of this feature that contains both representation (if any) and comment (if any).
 String getFullRepresentation(String separator)
          Prints a full representation of this feature that contains both representation (if any) and comment (if any).
abstract  String getRepresentation()
          Abstract method for returning the representation of this feature, to be used for classification.
 float getStrength()
          Returns a strength value for this feature.
 int hashCode()
          Returns a hash code value for this object, fulfulling the Object.hashCode() contract.
 String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Feature

public Feature()
Creates a new instance, without storing a comment.


Feature

public Feature(String myComment)
Creates a new instance.

Parameters:
myComment - a comment on this feature, ignored for classification; might be null
Method Detail

equals

public boolean equals(Object obj)
Indicates whether some other object is "equal to" this one, fulfulling the Object.equals(java.lang.Object) contract. To be considered equal, the object must be a Feature. If the representation of this instance is not null, the representations of the two features are compared. Otherwise the full representations are compared. Thus for normal features comments and other fields will be ignored. For comment-only features, comments will be considered, other fields will be ignored.

Overrides:
equals in class Object
Parameters:
obj - the reference object with which to compare
Returns:
true iff the specified object is a Feature equal to this instance

getComment

public String getComment()
Returns the comment attached to this feature, if any.

Returns:
the comment, or null is no comment was stored

getFullRepresentation

public String getFullRepresentation()
Prints a full representation of this feature that contains both representation (if any) and comment (if any). The comment is preceded by a "#" character.

Returns:
the full representation

getFullRepresentation

public String getFullRepresentation(String separator)
Prints a full representation of this feature that contains both representation (if any) and comment (if any). The comment is preceded by the specified separator (surrounded by spaces).

Parameters:
separator - used to introduce the comment
Returns:
the full representation

getRepresentation

public abstract String getRepresentation()
Abstract method for returning the representation of this feature, to be used for classification.

Returns:
the feature representation, or null if this feature contains only a comment

getStrength

public float getStrength()
Returns a strength value for this feature. This method can be overwritten to assign higher strenghts to more important or more frequent features. This implementation always returns 1.0.

Typically you should call FeatureVector.strength(Feature) instead of this method to allow feature vectors to modify the strenghts of the stored features.

Returns:
a strength value for this feature -- 1.0 in this implementation

hashCode

public int hashCode()
Returns a hash code value for this object, fulfulling the Object.hashCode() contract.

Overrides:
hashCode in class Object
Returns:
a hash code value for this object

toString

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

Overrides:
toString in class Object
Returns:
a textual representation


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