edu.stanford.nlp.ling
Class AbstractMapLabel

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

public abstract class AbstractMapLabel
extends Object
implements Label, HasWord, HasTag, HasCategory, HasContext, Serializable

An abstract class for Label objects which store attributes in a Map. Also implements HasWord, HasTag, HasCategory, and HasContext by storing the words, tags, etc. under standardized keys in the Map.

For convenience, this class also contains standardized keys for storing many other possible label attributes, such as head words, ner tags, etc.

Author:
grenager
See Also:
Serialized Form

Field Summary
static String AFTER_KEY
          the standard key for the String that comes after this word (from the InvertiblePTBTokenizer)
static String ANSWER_KEY
          The standard key for the answer which is a String
static String ARG_KEY
          The standard key for a propbank label which is of type Argument
static String BEFORE_KEY
          the standard key for the String that comes before this word (from the InvertiblePTBTokenizer)
static String CATEGORY_FUNCTIONAL_TAG_KEY
          The standard key for storing category with functional tags.
static String CATEGORY_KEY
          The standard key for storing a category in the map, as a String.
static String CURRENT_KEY
          the standard key for the actual, unmangled, pre-PTB'd word (from the InvertiblePTBTokenizer)
static String FEATURES_KEY
          The standard key for the features which is a Collection
static String GOLDANSWER_KEY
          The standard key for gold answer which is a String
static String HEAD_TAG_KEY
          The standard key for storing a head tag in the map as a pointer to another node.
static String HEAD_WORD_KEY
          The standard key for storing a head word in the map as a pointer to another node.
static String INDEX_KEY
          The standard key for storing an integer index in the map.
static String LEFT_TERM_KEY
          The Standard key for storing the left terminal number relative to the root of the tree of the leftmost terminal dominated by the current node
protected  Map map
          The Map which stores all of the attributes for this label, and the label value itself.
static String MARKING_KEY
          Another key used for propbank - to signify core arg nodes or predicate nodes
static String NER_KEY
          the standard key for the NER label.
static String PARENT_KEY
          The standard key for the parent which is a String
static String SEMANTIC_HEAD_POS_KEY
          The standard key for Semantic Head Word POS which is a String
static String SEMANTIC_HEAD_WORD_KEY
          The standard key for Semantic Head Word which is a String
static String SPAN_KEY
          The standard key for span which is a String
static String TAG_KEY
          The standard key for storing a tag in the map.
static String VALUE_KEY
          The standard key for storing a value in the map, as a String.
static String VERB_SENSE_KEY
          Probank key for the Verb sense given in the Propbank Annotation, should only be in the verbnode
static String WORD_KEY
          The standard key for storing a word in the map, as a String.
 
Constructor Summary
protected AbstractMapLabel()
           
 
Method Summary
 String after()
          Return the String after the word, which is stored in the map under the key AFTEr.
 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.
 String category()
          Return the category of the label (or null if none), which is stored in the map under the key CATEGORY_KEY.
 String current()
          Return the String which is the unmangled word, which is stored in the map under the key CURRENT.
 Object get(Object key)
          Returns the value to which the map contained in this label maps the specified key.
 Collection getFeatures()
           
 String getSemanticTag()
          Returns the semantic head pos of the phrase if it exists, and null otherwise
 String getSemanticWord()
          Returns the semantic head of the phrase if it exists, and null otherwise
 String goldAnswer()
          convenience method for getting gold answer *
 Object headTag()
           
 Object headWord()
          Return the head word of the label (or null if none), which is stored in the map under the key HEAD_WORD_KEY.
 int index()
          Return the index of the label (or -1 if none), which is stored in the map under the key INDEX_KEY.
 Map map()
          Return the Map contained in this label.
 String ner()
          Return the NER type of the word, which is stored in the map under the key NER.
 void prependBefore(String before)
          Prepend this String to the current before String
 Object put(Object key, Object value)
          Associates the specified value with the specified key in the map contained in this label.
 void setAfter(String after)
          Set the String after the word by storing it in the map under the key AFTER.
 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}.
 void setCategory(String category)
          Set the category for the label.
 void setCurrent(String current)
          Set the String which is the unmangled word, which is stored in the map under the key CURRENT.
 void setFeatures(Collection features)
           
 void setFromString(String str)
          Set value for the label from a String.
 void setGoldAnswer(String goldAnswer)
          convenience method for setting gold answer *
 void setHeadTag(Object headTagPtr)
          Set a pointer to the head-word for the label.
 void setHeadWord(Object headWordPtr)
          Set a pointer to the head-word for the label.
 int setIndex(int index)
          Set the index for the label by storing it in the contained map under the key INDEX_KEY.
 void setMap(Map map)
          Set the Map contained in this AbstractMapLabel to the supplied Map.
 void setNER(String ner)
          Set the NER label for the word, using the key NER.
 void setSemanticTag(String hTag)
          Set the semantic head pos of the phrase
 void setSemanticWord(String hWord)
          Set the semantic head of the phrase
 void setSpan(String span)
           
 void setTag(String tag)
          Set the head tag for the label by storing it in the map under the key HEAD_TAG_KEY.
 void setValue(String value)
          Set the value for the label.
 void setWord(String word)
          Set the word for the label.
 IntPair span()
          The span of this node as begin and end positions if it exists
 String tag()
          Return the head tag of the label (or null if none), which is stored in the map under the key TAG_KEY.
 String value()
          Return a String representation of just the "main" value of this label.
 String word()
          Return the word of the label, stored in the map under the key WORD_KEY.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.stanford.nlp.ling.Label
labelFactory, toString
 

Field Detail

VALUE_KEY

public static final String VALUE_KEY
The standard key for storing a value in the map, as a String.

See Also:
Constant Field Values

TAG_KEY

public static final String TAG_KEY
The standard key for storing a tag in the map.

See Also:
Constant Field Values

WORD_KEY

public static final String WORD_KEY
The standard key for storing a word in the map, as a String.

See Also:
Constant Field Values

CATEGORY_KEY

public static final String CATEGORY_KEY
The standard key for storing a category in the map, as a String.

See Also:
Constant Field Values

HEAD_WORD_KEY

public static final String HEAD_WORD_KEY
The standard key for storing a head word in the map as a pointer to another node.

See Also:
Constant Field Values

HEAD_TAG_KEY

public static final String HEAD_TAG_KEY
The standard key for storing a head tag in the map as a pointer to another node.

See Also:
Constant Field Values

INDEX_KEY

public static final String INDEX_KEY
The standard key for storing an integer index in the map.

See Also:
Constant Field Values

ARG_KEY

public static final String ARG_KEY
The standard key for a propbank label which is of type Argument

See Also:
Constant Field Values

MARKING_KEY

public static final String MARKING_KEY
Another key used for propbank - to signify core arg nodes or predicate nodes

See Also:
Constant Field Values

SEMANTIC_HEAD_WORD_KEY

public static final String SEMANTIC_HEAD_WORD_KEY
The standard key for Semantic Head Word which is a String

See Also:
Constant Field Values

SEMANTIC_HEAD_POS_KEY

public static final String SEMANTIC_HEAD_POS_KEY
The standard key for Semantic Head Word POS which is a String

See Also:
Constant Field Values

VERB_SENSE_KEY

public static final String VERB_SENSE_KEY
Probank key for the Verb sense given in the Propbank Annotation, should only be in the verbnode

See Also:
Constant Field Values

CATEGORY_FUNCTIONAL_TAG_KEY

public static final String CATEGORY_FUNCTIONAL_TAG_KEY
The standard key for storing category with functional tags.

See Also:
Constant Field Values

NER_KEY

public static final String NER_KEY
the standard key for the NER label.

See Also:
Constant Field Values

LEFT_TERM_KEY

public static final String LEFT_TERM_KEY
The Standard key for storing the left terminal number relative to the root of the tree of the leftmost terminal dominated by the current node

See Also:
Constant Field Values

PARENT_KEY

public static final String PARENT_KEY
The standard key for the parent which is a String

See Also:
Constant Field Values

SPAN_KEY

public static final String SPAN_KEY
The standard key for span which is a String

See Also:
Constant Field Values

BEFORE_KEY

public static final String BEFORE_KEY
the standard key for the String that comes before this word (from the InvertiblePTBTokenizer)

See Also:
Constant Field Values

AFTER_KEY

public static final String AFTER_KEY
the standard key for the String that comes after this word (from the InvertiblePTBTokenizer)

See Also:
Constant Field Values

CURRENT_KEY

public static final String CURRENT_KEY
the standard key for the actual, unmangled, pre-PTB'd word (from the InvertiblePTBTokenizer)

See Also:
Constant Field Values

ANSWER_KEY

public static String ANSWER_KEY
The standard key for the answer which is a String


GOLDANSWER_KEY

public static String GOLDANSWER_KEY
The standard key for gold answer which is a String


FEATURES_KEY

public static String FEATURES_KEY
The standard key for the features which is a Collection


map

protected Map map
The Map which stores all of the attributes for this label, and the label value itself.

Constructor Detail

AbstractMapLabel

protected AbstractMapLabel()
Method Detail

map

public Map map()
Return the Map contained in this label.

Returns:
the Map contained in this AbstractMapLabel

setMap

public void setMap(Map map)
Set the Map contained in this AbstractMapLabel to the supplied Map.

Parameters:
map - the new Map for this label

get

public Object get(Object key)
Returns the value to which the map contained in this label maps the specified key. Returns null if the map contains no mapping for this key. (Analogous to Map.get(Object key).)

Parameters:
key - key whose associated value is to be returned.
Returns:
the value to which the map contained in this label maps the specified key, or null if the map contains no mapping for this key.

put

public Object put(Object key,
                  Object value)
Associates the specified value with the specified key in the map contained in this label. (Analogous to Map.put(Object key, Object value).) If the map previously contained a mapping for this key, the old value is replaced by the specified value.

Parameters:
key - key with which the specified value is to be associated.
value - value to be associated with the specified key.
Returns:
previous value associated with specified key, or null if there was no mapping for key.

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
Returns:
the value for the label

setValue

public void setValue(String value)
Set the value for the label.

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

setFromString

public void setFromString(String str)
Set value for the label from a String.

Specified by:
setFromString in interface Label
Parameters:
str - the string value for the label

category

public String category()
Return the category of the label (or null if none), which is stored in the map under the key CATEGORY_KEY.

Specified by:
category in interface HasCategory
Returns:
the category for the label

setCategory

public void setCategory(String category)
Set the category for the label.

Specified by:
setCategory in interface HasCategory
Parameters:
category - the category for the label

word

public String word()
Return the word of the label, stored in the map under the key WORD_KEY.

Specified by:
word in interface HasWord
Returns:

setWord

public void setWord(String word)
Set the word for the label.

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

span

public IntPair span()
The span of this node as begin and end positions if it exists

Returns:

setSpan

public void setSpan(String span)

headWord

public Object headWord()
Return the head word of the label (or null if none), which is stored in the map under the key HEAD_WORD_KEY.

Returns:
the head word for the label

setHeadWord

public void setHeadWord(Object headWordPtr)
Set a pointer to the head-word for the label.


getSemanticWord

public String getSemanticWord()
Returns the semantic head of the phrase if it exists, and null otherwise


setSemanticWord

public void setSemanticWord(String hWord)
Set the semantic head of the phrase


getSemanticTag

public String getSemanticTag()
Returns the semantic head pos of the phrase if it exists, and null otherwise


setSemanticTag

public void setSemanticTag(String hTag)
Set the semantic head pos of the phrase


tag

public String tag()
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
Returns:
the head tag for the label

setTag

public void setTag(String tag)
Set the head tag for the label by storing it in the map under the key HEAD_TAG_KEY.

Specified by:
setTag in interface HasTag
Parameters:
tag - the head tag for the label

headTag

public Object headTag()

setHeadTag

public void setHeadTag(Object headTagPtr)
Set a pointer to the head-word for the label.


ner

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

Returns:
the String after the word

setNER

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

Parameters:
ner - The String ner the word

index

public int index()
Return the index of the label (or -1 if none), which is stored in the map under the key INDEX_KEY.

Returns:
the index for the label

setIndex

public int setIndex(int index)
Set the index for the label by storing it in the contained map under the key INDEX_KEY. Returns the old index (or -1 if none).

Returns:
the old index for the label (or -1 if none).

before

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

Specified by:
before in interface HasContext
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}.

Specified by:
setBefore in interface HasContext
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
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.

Specified by:
current in interface HasContext
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.

Specified by:
setCurrent in interface HasContext
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.

Specified by:
after in interface HasContext
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.

Specified by:
setAfter in interface HasContext
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
Parameters:
after - The String to be prepended

answer

public String answer()
convenience method for getting answer *


setAnswer

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


goldAnswer

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


setGoldAnswer

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


getFeatures

public Collection getFeatures()

setFeatures

public void setFeatures(Collection features)


Stanford NLP Group