edu.stanford.nlp.ling
Class RVFDatum<L,F>

java.lang.Object
  extended by edu.stanford.nlp.ling.RVFDatum<L,F>
Type Parameters:
L - The type of the label of the datum
F - The type of individual features stored in the datum
All Implemented Interfaces:
Datum<L,F>, Featurizable<F>, Labeled<L>, java.io.Serializable

public class RVFDatum<L,F>
extends java.lang.Object
implements Datum<L,F>

A basic implementation of the Datum interface that can be constructed with a Collection of features and one more more labels. The features must be specified at construction, but the labels can be set and/or changed later.

Author:
Jenny Finkel jrfinkel@stanford.edu, Sarah Spikes (sdspikes@stanford.edu) [templatized]
See Also:
Serialized Form

Constructor Summary
RVFDatum()
          Constructs a new RVFDatum with no features or labels.
RVFDatum(Counter<F> features)
          Constructs a new RVFDatum with the given features and no labels.
RVFDatum(Counter<F> features, L label)
          Constructs a new RVFDatum with the given features and label.
RVFDatum(Datum<L,F> m)
          Constructs a new RVFDatum taking the data from a Datum.
 
Method Summary
 java.util.Collection<F> asFeatures()
          Returns the list of features without values
 Counter<F> asFeaturesCounter()
          Returns the Counter of features and values
 boolean equals(java.lang.Object o)
          Returns whether the given RVFDatum contains the same features with the same values as this RVFDatum.
 int hashCode()
          
 L label()
          Returns the primary label for this Object, or null if none have been set.
 java.util.Collection<L> labels()
          Returns the complete list of labels for this Object, which may be empty.
 void setLabel(L label)
          Removes all currently assigned Labels for this Datum then adds the given Label.
 java.lang.String toString()
          Returns a String representation of this BasicDatum (lists features and labels).
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RVFDatum

public RVFDatum(Counter<F> features,
                L label)
Constructs a new RVFDatum with the given features and label.


RVFDatum

public RVFDatum(Datum<L,F> m)
Constructs a new RVFDatum taking the data from a Datum. Implementation note: This constructor allocates its own counter over features, but is only guaranteed correct if the label and feature names are immutable.

Parameters:
m - The Datum to copy.

RVFDatum

public RVFDatum(Counter<F> features)
Constructs a new RVFDatum with the given features and no labels.


RVFDatum

public RVFDatum()
Constructs a new RVFDatum with no features or labels.

Method Detail

asFeaturesCounter

public Counter<F> asFeaturesCounter()
Returns the Counter of features and values


asFeatures

public java.util.Collection<F> asFeatures()
Returns the list of features without values

Specified by:
asFeatures in interface Featurizable<F>

setLabel

public void setLabel(L label)
Removes all currently assigned Labels for this Datum then adds the given Label. Calling setLabel(null) effectively clears all labels.


toString

public java.lang.String toString()
Returns a String representation of this BasicDatum (lists features and labels).

Overrides:
toString in class java.lang.Object

label

public L label()
Description copied from interface: Labeled
Returns the primary label for this Object, or null if none have been set.

Specified by:
label in interface Labeled<L>

labels

public java.util.Collection<L> labels()
Description copied from interface: Labeled
Returns the complete list of labels for this Object, which may be empty.

Specified by:
labels in interface Labeled<L>

equals

public boolean equals(java.lang.Object o)
Returns whether the given RVFDatum contains the same features with the same values as this RVFDatum. An RVFDatum can only be equal to another RVFDatum. Implementation note: Doesn't check the labels, should we change this?

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object


Stanford NLP Group