edu.stanford.nlp.ling
Class FeatureLabel

java.lang.Object
  extended by edu.stanford.nlp.ling.AbstractMapLabel
      extended by edu.stanford.nlp.ling.FeatureLabel
All Implemented Interfaces:
HasCategory, HasContext, HasTag, HasWord, Label, Serializable

public class FeatureLabel
extends AbstractMapLabel

An AbstractMapLabel implementation which defines equality as equality of the internal map. Thus it is NOT SAFE for use in cyclic data structures, in which the map may point to something which in turn points to this map again, as calling equals() will lead to an infinite recursion.

As standardly used, both a key and the corresponding value of a FeatureLabel are of type String.

Author:
Jenny Finkel, Teg Grenager
See Also:
Serialized Form

Field Summary
 Collection features
           
static String TOSTRING_FORMAT
           
 
Fields inherited from class edu.stanford.nlp.ling.AbstractMapLabel
AFTER_KEY, ANSWER_KEY, ARG_KEY, BEFORE_KEY, CATEGORY_FUNCTIONAL_TAG_KEY, CATEGORY_KEY, CH_CHAR_KEY, CH_ORIG_SEG_KEY, CH_SEG_KEY, CURRENT_KEY, FEATURES_KEY, GAZETTEER_KEY, GOLDANSWER_KEY, HEAD_TAG_KEY, HEAD_WORD_KEY, INDEX_KEY, INTERPRETATION_KEY, LEFT_TERM_KEY, LEMMA_KEY, map, mapFactory, MARKING_KEY, NER_KEY, PARENT_KEY, POLARITY_KEY, PROJ_CAT_KEY, ROLE_KEY, SEMANTIC_HEAD_POS_KEY, SEMANTIC_HEAD_WORD_KEY, SHAPE_KEY, SPAN_KEY, STEM_KEY, TAG_KEY, VALUE_KEY, VERB_SENSE_KEY, WORD_KEY
 
Constructor Summary
FeatureLabel()
           
FeatureLabel(AbstractMapLabel other)
          Copy constructor.
FeatureLabel(Map map)
          Copy constructor.
FeatureLabel(MapFactory mapFactory)
           
FeatureLabel(String[] keys, String[] values)
           
 
Method Summary
 String after()
          Return the String after the word, which is stored in the map under the key AFTER_KEY.
 String answer()
          convenience method for getting answer *
 void appendAfter(String after)
          Append this String to the current after String
 String before()
          Return the String before the word, which is stored in the map under the key BEFORE_KEY.
 String current()
          Return the String which is the unmangled word, which is stored in the map under the key CURRENT_KEY.
 boolean equals(Object o)
           
static LabelFactory factory()
           
 String getString(Object attribute)
          Return the String value of the FeatureLabel for an arbitrary key.
 String goldAnswer()
          convenience method for getting gold answer *
 int hashCode()
           
 void internValues(Interner interner)
          Interns all of the keys and values in the underlying map of this FeatureLabel.
 Set keySet()
           
 LabelFactory labelFactory()
          Returns a factory that makes labels of the exact same type as this one.
 String lemma()
           
 Map map()
          Return the Map contained in this label.
static String[] mapStringToArray(String map)
           
 String ner()
          Return the NER type of the word, which is stored in the map under the key NER_KEY.
 void prependBefore(String before)
          Prepend this String to the current before String
 void remove(String key)
           
 void set(Object attribute, Object value)
           
 void setAfter(String after)
          Set the String after the word by storing it in the map under the key AFTER_KEY.
 void setAnswer(String answer)
          convenience method for setting answer *
 void setBefore(String before)
          Set the String before the word by storing it in the map under the key BEFORE_KEY.
 void setCurrent(String current)
          Set the String which is the unmangled word, which is stored in the map under the key CURRENT_KEY.
 void setFromString(String labelStr)
          Set value for the label from a String.
 void setGoldAnswer(String goldAnswer)
          convenience method for setting gold answer *
 void setNER(String ner)
          Set the NER label for the word, using the key NER_KEY.
 void setValue(String value)
          Set the value for the label.
 void setWord(String word)
          convenience method for setting word *
 String tag()
          Return the head tag of the label (or null if none), which is stored in the map under the key TAG_KEY.
static String toOriginalString(List<FeatureLabel> sentence)
          Pieces a List of MapLabels back together using before, after and current.
static String toSentence(List<FeatureLabel> sentence)
          Pieces a List of MapLabels back together using word and setting a white space between each word
 String toString()
          Return a String representation of the label.
 String toString(String format)
           
 String value()
          Return a String representation of just the "main" value of this label.
static FeatureLabel valueOf(String s, MapFactory mf)
          Uses String representation of a Map to populate Map with String keys and String values.
 String word()
          convenience method for getting word *
 
Methods inherited from class edu.stanford.nlp.ling.AbstractMapLabel
category, get, getFeatures, getLemma, getRole, getSemanticTag, getSemanticWord, headTag, headWord, index, interpretation, put, setCategory, setFeatures, setHeadTag, setHeadWord, setIndex, setInterpretation, setLemma, setRole, setSemanticTag, setSemanticWord, setShape, setSpan, setTag, shape, span
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TOSTRING_FORMAT

public static String TOSTRING_FORMAT

features

public Collection features
Constructor Detail

FeatureLabel

public FeatureLabel()

FeatureLabel

public FeatureLabel(MapFactory mapFactory)

FeatureLabel

public FeatureLabel(String[] keys,
                    String[] values)
Parameters:
keys -
values -

FeatureLabel

public FeatureLabel(AbstractMapLabel other)
Copy constructor. Makes a new FeatureLabel using the MapFactory and Map contents of the other AbstractMapLabel.


FeatureLabel

public FeatureLabel(Map map)
Copy constructor. Makes a new FeatureLabel using the MapFactory and Map contents of the other AbstractMapLabel.

Method Detail

keySet

public Set keySet()

valueOf

public static FeatureLabel valueOf(String s,
                                   MapFactory mf)
                            throws Exception
Uses String representation of a Map to populate Map with String keys and String values.

Throws:
Exception

mapStringToArray

public static String[] mapStringToArray(String map)

word

public String word()
convenience method for getting word *

Specified by:
word in interface HasWord
Overrides:
word in class AbstractMapLabel
Returns:
The word for this label

answer

public String answer()
convenience method for getting answer *

Overrides:
answer in class AbstractMapLabel

goldAnswer

public String goldAnswer()
convenience method for getting gold answer *

Overrides:
goldAnswer in class AbstractMapLabel

setWord

public void setWord(String word)
convenience method for setting word *

Specified by:
setWord in interface HasWord
Overrides:
setWord in class AbstractMapLabel
Parameters:
word - the head word for the label

setAnswer

public void setAnswer(String answer)
convenience method for setting answer *

Overrides:
setAnswer in class AbstractMapLabel

setGoldAnswer

public void setGoldAnswer(String goldAnswer)
convenience method for setting gold answer *

Overrides:
setGoldAnswer in class AbstractMapLabel

before

public String before()
Return the String before the word, which is stored in the map under the key BEFORE_KEY.

Specified by:
before in interface HasContext
Overrides:
before in class AbstractMapLabel
Returns:
the String before the word

setBefore

public void setBefore(String before)
Set the String before the word by storing it in the map under the key BEFORE_KEY.

Specified by:
setBefore in interface HasContext
Overrides:
setBefore in class AbstractMapLabel
Parameters:
before - the String before the word

prependBefore

public void prependBefore(String before)
Prepend this String to the current before String

Specified by:
prependBefore in interface HasContext
Overrides:
prependBefore in class AbstractMapLabel
Parameters:
before - the String to be prepended

current

public String current()
Return the String which is the unmangled word, which is stored in the map under the key CURRENT_KEY.

Specified by:
current in interface HasContext
Overrides:
current in class AbstractMapLabel
Returns:
the unmangled word

setCurrent

public void setCurrent(String current)
Set the String which is the unmangled word, which is stored in the map under the key CURRENT_KEY.

Specified by:
setCurrent in interface HasContext
Overrides:
setCurrent in class AbstractMapLabel
Parameters:
current - the unmangled word

after

public String after()
Return the String after the word, which is stored in the map under the key AFTER_KEY.

Specified by:
after in interface HasContext
Overrides:
after in class AbstractMapLabel
Returns:
the String after the word

setAfter

public void setAfter(String after)
Set the String after the word by storing it in the map under the key AFTER_KEY.

Specified by:
setAfter in interface HasContext
Overrides:
setAfter in class AbstractMapLabel
Parameters:
after - The String after the word

appendAfter

public void appendAfter(String after)
Append this String to the current after String

Specified by:
appendAfter in interface HasContext
Overrides:
appendAfter in class AbstractMapLabel
Parameters:
after - The String to be prepended

ner

public String ner()
Return the NER type of the word, which is stored in the map under the key NER_KEY.

Overrides:
ner in class AbstractMapLabel
Returns:
the String after the word

setNER

public void setNER(String ner)
Set the NER label for the word, using the key NER_KEY.

Overrides:
setNER in class AbstractMapLabel
Parameters:
ner - The String ner the word

toOriginalString

public static String toOriginalString(List<FeatureLabel> sentence)
Pieces a List of MapLabels back together using before, after and current.


toSentence

public static String toSentence(List<FeatureLabel> sentence)
Pieces a List of MapLabels back together using word and setting a white space between each word


value

public String value()
Description copied from interface: Label
Return a String representation of just the "main" value of this label.

Specified by:
value in interface Label
Overrides:
value in class AbstractMapLabel
Returns:
the value for the label

setValue

public void setValue(String value)
Description copied from class: AbstractMapLabel
Set the value for the label.

Specified by:
setValue in interface Label
Overrides:
setValue in class AbstractMapLabel
Parameters:
value - the value for the label

toString

public String toString()
Description copied from interface: Label
Return a String representation of the label. For a multipart label, this will return all parts. The toString() method causes a label to spill its guts. It should always return an empty string rather than null if there is no value.

Specified by:
toString in interface Label
Overrides:
toString in class Object
Returns:
a text representation of the full label contents

toString

public String toString(String format)

setFromString

public void setFromString(String labelStr)
Description copied from class: AbstractMapLabel
Set value for the label from a String.

Specified by:
setFromString in interface Label
Overrides:
setFromString in class AbstractMapLabel
Parameters:
labelStr - the string value for the label

labelFactory

public LabelFactory labelFactory()
Description copied from interface: Label
Returns a factory that makes labels of the exact same type as this one. May return null if no appropriate factory is known.

Returns:
the LabelFactory for this kind of label

factory

public static LabelFactory factory()

internValues

public void internValues(Interner interner)
Interns all of the keys and values in the underlying map of this FeatureLabel.

Parameters:
interner -

lemma

public String lemma()

tag

public String tag()
Description copied from class: AbstractMapLabel
Return the head tag of the label (or null if none), which is stored in the map under the key TAG_KEY.

Specified by:
tag in interface HasTag
Overrides:
tag in class AbstractMapLabel
Returns:
the head tag for the label

getString

public String getString(Object attribute)
Return the String value of the FeatureLabel for an arbitrary key. See AbstractMapLabel for standard attribute key names, though anything can be used. The return value of this method is always a non-null String. If the attribute does not exist in the Map, then the empty String is returned.

Note: This behavior is central to how our IE systems work and should not be changed!!


set

public void set(Object attribute,
                Object value)

map

public Map map()
Description copied from class: AbstractMapLabel
Return the Map contained in this label.

Overrides:
map in class AbstractMapLabel
Returns:
the Map contained in this AbstractMapLabel

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

remove

public void remove(String key)


Stanford NLP Group