edu.stanford.nlp.ling
Class BasicDatum

java.lang.Object
  extended by edu.stanford.nlp.ling.BasicDatum
All Implemented Interfaces:
Datum, Featurizable, Labeled, Serializable

public class BasicDatum
extends Object
implements Datum

Basic implementation of 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:
Joseph Smarr (jsmarr@stanford.edu)
See Also:
Serialized Form

Constructor Summary
BasicDatum()
          Constructs a new BasicDatum with no features or labels.
BasicDatum(Collection features)
          Constructs a new BasicDatum with the given features and no labels.
BasicDatum(Collection features, Collection labels)
          Constructs a new BasicDatum with the given features and labels.
BasicDatum(Collection features, Object label)
          Constructs a new BasicDatum with the given features and label.
 
Method Summary
 void addLabel(Object label)
          Adds the given Label to the List of labels for this Datum if it is not null.
 Collection asFeatures()
          Returns the collection that this BasicDatum was constructed with.
 boolean equals(Object o)
          Returns whether the given Datum contains the same features as this Datum.
 Object label()
          Returns the first label for this Datum, or null if none have been set.
 Collection labels()
          Returns the complete List of labels for this Datum, which may be empty.
 void setLabel(Object label)
          Removes all currently assigned Labels for this Datum then adds the given Label.
 void setLabels(Collection labels)
          Removes all currently assigned labels for this Datum then adds all of the given Labels.
 String toString()
          Returns a String representation of this BasicDatum (lists features and labels).
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasicDatum

public BasicDatum(Collection features,
                  Collection labels)
Constructs a new BasicDatum with the given features and labels.


BasicDatum

public BasicDatum(Collection features,
                  Object label)
Constructs a new BasicDatum with the given features and label.


BasicDatum

public BasicDatum(Collection features)
Constructs a new BasicDatum with the given features and no labels.


BasicDatum

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

Method Detail

asFeatures

public Collection asFeatures()
Returns the collection that this BasicDatum was constructed with.

Specified by:
asFeatures in interface Featurizable

label

public Object label()
Returns the first label for this Datum, or null if none have been set.

Specified by:
label in interface Labeled

labels

public Collection labels()
Returns the complete List of labels for this Datum, which may be empty.

Specified by:
labels in interface Labeled

setLabel

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


setLabels

public void setLabels(Collection labels)
Removes all currently assigned labels for this Datum then adds all of the given Labels.


addLabel

public void addLabel(Object label)
Adds the given Label to the List of labels for this Datum if it is not null.


toString

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

Overrides:
toString in class Object

equals

public boolean equals(Object o)
Returns whether the given Datum contains the same features as this Datum. Doesn't check the labels, should we change this?

Overrides:
equals in class Object


Stanford NLP Group