|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.nlp.ling.AbstractLabel
edu.stanford.nlp.ling.MapLabel
public class MapLabel
A MapLabel
object contains a Map
, which
in turn may contain arbitrary key-value pairs. The primary
value
(corresponding to the string in a
StringLabel
, and representing a category in a parse
tree) is stored in the map under the key
.CATEGORY_KEY
For convenience, this class also contains standardized keys for storing head words, head tags, and integer indexes in the map, under the keys
HEAD_WORD_KEY
, HEAD_TAG_KEY
, and INDEX_KEY
, respectively. It also provides methods
for getting and setting the category, head word, head tag, and
index.
Field Summary | |
---|---|
static java.lang.String |
ARG
The standard key for a propbank label which is of type Argument |
static java.lang.String |
CATEGORY_FUNCTIONAL_TAG_KEY
The standard key for storing category with functional tags. |
static java.lang.String |
CATEGORY_KEY
The standard key for storing a category (value) in the map. |
static java.lang.String |
HEAD_TAG_KEY
The standard key for storing a head tag in the map. |
static java.lang.String |
HEAD_WORD_KEY
The standard key for storing a head word in the map. |
static java.lang.String |
INDEX_KEY
The standard key for storing an integer index in the map. |
static java.lang.String |
MARKING
Another key used for propbank - to signify core arg nodes or predicate nodes |
static java.lang.String |
SEMANTIC_HEAD_POS_KEY
The standard key for Semantic Head Word POS which is a String |
static java.lang.String |
SEMANTIC_HEAD_WORD_KEY
The standard key for Semantic Head Word which is a String |
Constructor Summary | |
---|---|
MapLabel()
Create a new MapLabel with null value. |
|
MapLabel(Label label)
Create a new MapLabel with the value of another
Label as its value. |
|
MapLabel(java.lang.String str)
Create a new MapLabel with the given value. |
Method Summary | |
---|---|
java.lang.String |
category()
Return the category of the label (or null if
none), which is stored in the map under the key . |
boolean |
equals(java.lang.Object o)
Equality for Label s is defined in the first instance
as equality of their String value() . |
static LabelFactory |
factory()
Return a factory for MapLabel s. |
java.lang.Object |
get(java.lang.Object key)
Returns the value to which the map contained in this label maps the specified key. |
java.lang.String |
getSemanticTag()
Returns the semantic head pos of the phrase if it exists, and null otherwise |
java.lang.String |
getSemanticWord()
Returns the semantic head of the phrase if it exists, and null otherwise |
int |
index()
Return the index of the label (or -1 if none), which is stored in the map under the key . |
LabelFactory |
labelFactory()
Return a factory for MapLabel s. |
static void |
main(java.lang.String[] args)
For testing only. |
java.util.Map |
map()
Return the Map contained in this label. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Associates the specified value with the specified key in the map contained in this label. |
void |
setCategory(java.lang.String category)
Set the category for the label by storing it in the map under the key . |
void |
setFromString(java.lang.String str)
Set value for the label from a String by storing it in the map under the key . |
int |
setIndex(int index)
Set the index for the label by storing it in the contained map under the key . |
void |
setMap(java.util.Map map)
Set the Map contained in this label to the
supplied Map . |
void |
setSemanticTag(java.lang.String hTag)
Set the semantic head pos of the phrase |
void |
setSemanticWord(java.lang.String hWord)
Set the semantic head of the phrase |
void |
setTag(java.lang.String tag)
Set the head tag for the label by storing it in the map under the key . |
void |
setValue(java.lang.String value)
Set the value for the label by storing it in the map under the key . |
void |
setWord(java.lang.String word)
Set the head word for the label by storing it in the map under the key . |
java.lang.String |
tag()
Return the head tag of the label (or null if none),
which is stored in the map under the key . |
java.lang.String |
toString()
Return a String containing the value (and index,
if any) of this label. |
java.lang.String |
toString(java.lang.String format)
Returns a formatted string representing this label. |
java.lang.String |
value()
Return the value of the label (or null if none),
which is stored in the map under the key . |
java.lang.String |
word()
Return the head word of the label (or null if
none), which is stored in the map under the key . |
Methods inherited from class edu.stanford.nlp.ling.AbstractLabel |
---|
compareTo, hashCode |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String CATEGORY_KEY
public static final java.lang.String HEAD_WORD_KEY
public static final java.lang.String HEAD_TAG_KEY
public static final java.lang.String INDEX_KEY
public static final java.lang.String ARG
public static final java.lang.String MARKING
public static final java.lang.String SEMANTIC_HEAD_WORD_KEY
public static final java.lang.String SEMANTIC_HEAD_POS_KEY
public static final java.lang.String CATEGORY_FUNCTIONAL_TAG_KEY
Constructor Detail |
---|
public MapLabel()
MapLabel
with null value.
public MapLabel(java.lang.String str)
MapLabel
with the given value.
str
- the value of the new labelpublic MapLabel(Label label)
MapLabel
with the value of another
Label
as its value.If the argument label is a
MapLabel
, the new
label is identical to the argument label (but does not share
storage).If the argument label is a
CategoryWordTag
, the category, word, and tag are
stored in the map of the new label under the map keys CATEGORY_KEY
, HEAD_WORD_KEY
, and HEAD_TAG_KEY
,
respectively.
label
- the other labelMethod Detail |
---|
public boolean equals(java.lang.Object o)
AbstractLabel
Label
s is defined in the first instance
as equality of their String
value()
.
Now rewritten to correctly enforce the contract of equals in Object.
Equality for a Label
is determined simply by String
equality of its value()
. Subclasses should not redefine
this to include other aspects of the Label
, or the
contract for equals()
is broken.
equals
in class AbstractLabel
o
- the object against which equality is to be checked
this
and obj
are equalpublic java.lang.String value()
null
if none),
which is stored in the map under the key CATEGORY_KEY
.
value
in interface Label
value
in class AbstractLabel
public void setValue(java.lang.String value)
CATEGORY_KEY
.
setValue
in interface Label
setValue
in class AbstractLabel
value
- the value for the labelpublic void setFromString(java.lang.String str)
CATEGORY_KEY
.
setFromString
in interface Label
setFromString
in class AbstractLabel
str
- the string value for the labelpublic java.lang.String category()
null
if
none), which is stored in the map under the key CATEGORY_KEY
.
category
in interface HasCategory
public void setCategory(java.lang.String category)
CATEGORY_KEY
.
setCategory
in interface HasCategory
category
- the category for the labelpublic java.lang.String word()
null
if
none), which is stored in the map under the key HEAD_WORD_KEY
.
word
in interface HasWord
public java.lang.String getSemanticWord()
public void setSemanticWord(java.lang.String hWord)
public java.lang.String getSemanticTag()
public void setSemanticTag(java.lang.String hTag)
public void setWord(java.lang.String word)
HEAD_WORD_KEY
.
setWord
in interface HasWord
word
- the head word for the labelpublic java.lang.String tag()
null
if none),
which is stored in the map under the key HEAD_TAG_KEY
.
tag
in interface HasTag
public void setTag(java.lang.String tag)
HEAD_TAG_KEY
.
setTag
in interface HasTag
tag
- the head tag for the labelpublic java.util.Map map()
Map
contained in this label.
Map
contained in this labelpublic void setMap(java.util.Map map)
Map
contained in this label to the
supplied Map
.
map
- the new Map
for this labelpublic int index()
INDEX_KEY
.
public int setIndex(int index)
INDEX_KEY
. Returns the old index (or -1 if none).
public java.lang.Object get(java.lang.Object key)
null
if the map
contains no mapping for this key. (Analogous to Map.get(Object key)
.)
key
- key whose associated value is to be returned.
null
if the map
contains no mapping for this key.public java.lang.Object put(java.lang.Object key, java.lang.Object value)
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.
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.
null
if there was no mapping for key.public LabelFactory labelFactory()
MapLabel
s.
The factory returned is always the same one (a singleton).
labelFactory
in interface Label
labelFactory
in class AbstractLabel
public static LabelFactory factory()
MapLabel
s.
The factory returned is always the same one (a singleton).
public java.lang.String toString()
String
containing the value (and index,
if any) of this label. This is equivalent to
toString("value-index").
toString
in interface Label
toString
in class AbstractLabel
public java.lang.String toString(java.lang.String format)
String
.
Currently supported formats include:
CATEGORY_KEY
)
CATEGORY_KEY
and INDEX_KEY
,
respectively, and prints them with a hyphen in between
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |