method for that
interface corresponds to the word of the WordTag.
The equality relation for WordTag is defined as identity of both
word and tag. Note that this is different from
TaggedWord
, for which equality derives from
AbstractLabel
and requires only identity of value.
TaggedWord should be considered deprecated and the use of WordTag
is preferable.
- Author:
- Roger Levy
- See Also:
- Serialized Form
Method Summary |
int |
compareTo(Object obj)
Implementation of comparison for Label . |
boolean |
equals(Object obj)
Equality is satisfied only if the compared object is a WordTag
and has String-equal word and tag fields. |
static LabelFactory |
factory()
Return a factory for this kind of label. |
int |
hashCode()
|
LabelFactory |
labelFactory()
Return a factory for this kind of label
(i.e., TaggedWord ). |
static void |
setDivider(String divider)
Set the String (usually just a single character) used to mark
the separation between the word and the tag. |
void |
setFromString(String taggedWord)
Sets a TaggedWord from decoding
the String passed in. |
void |
setTag(String tag)
Set the tag value for the label (if one is stored). |
void |
setValue(String value)
Set the value for the label (if one is stored). |
void |
setWord(String word)
Set the word value for the label (if one is stored). |
String |
tag()
Return the tag value of the label (or null if none). |
String |
toString()
Return a String representation of the label. |
String |
value()
Return a String representation of just the "main" value of this label. |
String |
word()
Return the word value of the label (or null if none). |
WordTag
public WordTag(String word)
WordTag
public WordTag(Label word)
WordTag
public WordTag(String word,
String tag)
- Create a new
WordTag
.
- Parameters:
word
- This word is passed to the supertype constructortag
- The value()
of this label is set as the
tag of this Label
WordTag
public WordTag(Label word,
Label tag)
- Create a new
WordTag
from a Label. The value of
the Label corresponds to the word of the WordTag.
- Parameters:
word
- This word is passed to the supertype constructortag
- The value()
of this label is set as the
tag of this Label
value
public String value()
- Return a String representation of just the "main" value of this label.
- Specified by:
value
in interface Label
- Returns:
- the "value" of the label
word
public String word()
- Description copied from interface:
HasWord
- Return the word value of the label (or null if none).
- Specified by:
word
in interface HasWord
- Returns:
- String the word value for the label
setValue
public void setValue(String value)
- Set the value for the label (if one is stored).
- Specified by:
setValue
in interface Label
- Parameters:
value
- - the value for the label
tag
public String tag()
- Description copied from interface:
HasTag
- Return the tag value of the label (or null if none).
- Specified by:
tag
in interface HasTag
- Returns:
- String the tag value for the label
setWord
public void setWord(String word)
- Description copied from interface:
HasWord
- Set the word value for the label (if one is stored).
- Specified by:
setWord
in interface HasWord
- Parameters:
word
- The word value for the label
setTag
public void setTag(String tag)
- Description copied from interface:
HasTag
- Set the tag value for the label (if one is stored).
- Specified by:
setTag
in interface HasTag
- Parameters:
tag
- The tag value for the label
toString
public String toString()
- 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
setFromString
public void setFromString(String taggedWord)
- Sets a TaggedWord from decoding
the
String
passed in. The String is divided according
to the divider character (usually, "/"). We assume that we can
always just
divide on the rightmost divider character, rather than trying to
parse up escape sequences. If the divider character isn't found
in the word, then the whole string becomes the word, and the tag
is null
.
- Specified by:
setFromString
in interface Label
- Parameters:
taggedWord
- The word that will go into the Word
equals
public boolean equals(Object obj)
- Equality is satisfied only if the compared object is a WordTag
and has String-equal word and tag fields.
- Overrides:
equals
in class Object
hashCode
public int hashCode()
- Overrides:
hashCode
in class Object
compareTo
public int compareTo(Object obj)
- Implementation of comparison for
Label
.
By default this orders by value's string lexicographic ordering.
- Specified by:
compareTo
in interface Label
- Parameters:
obj
- object to compare to
- Returns:
- result (positive if
this
is greater than
obj
, 0 if equal, negative otherwise)
labelFactory
public LabelFactory labelFactory()
- Return a factory for this kind of label
(i.e.,
TaggedWord
).
The factory returned is always the same one (a singleton).
- Specified by:
labelFactory
in interface Label
- Returns:
- The label factory
factory
public static LabelFactory factory()
- Return a factory for this kind of label.
- Returns:
- The label factory
setDivider
public static void setDivider(String divider)
- Set the String (usually just a single character) used to mark
the separation between the word and the tag. This is used when
printing out a
TaggedWord
via the toString()
method, and when reading in a TaggedWord
via the
setFromString()
method.
Unless altered using this method, the default is "/".
- Parameters:
divider
- The String between words and tags
Stanford NLP Group