public class WordTag extends java.lang.Object implements Label, HasWord, HasTag, java.lang.Comparable<WordTag>
value()
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
ValueLabel
and requires only identity of value.
Constructor and Description |
---|
WordTag(E word) |
WordTag(Label word,
Label tag)
Create a new
WordTag from a Label. |
WordTag(java.lang.String word) |
WordTag(java.lang.String word,
java.lang.String tag)
Create a new
WordTag . |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(WordTag wordTag)
Orders first by word, then by tag.
|
boolean |
equals(java.lang.Object o)
A WordTag is equal only to another WordTag with the same word and tag values.
|
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 ). |
void |
read(java.io.DataInputStream in) |
void |
save(java.io.DataOutputStream out) |
void |
setFromString(java.lang.String wordTagString)
Sets a WordTag from decoding
the
String passed in. |
void |
setFromString(java.lang.String wordTagString,
java.lang.String divider) |
void |
setTag(java.lang.String tag)
Set the tag value for the label (if one is stored).
|
void |
setValue(java.lang.String value)
Set the value for the label (if one is stored).
|
void |
setWord(java.lang.String word)
Set the word value for the label (if one is stored).
|
java.lang.String |
tag()
Return the tag value of the label (or null if none).
|
java.lang.String |
toString()
Return a String representation of the label.
|
java.lang.String |
toString(java.lang.String divider) |
java.lang.String |
value()
Return a String representation of just the "main" value of this label.
|
static WordTag |
valueOf(java.lang.String s) |
static WordTag |
valueOf(java.lang.String s,
java.lang.String tagDivider) |
java.lang.String |
word()
Return the word value of the label (or null if none).
|
public WordTag(java.lang.String word, java.lang.String tag)
WordTag
.word
- This word is passed to the supertype constructortag
- The value()
of this label is set as the
tag of this Labelpublic WordTag(java.lang.String word)
public WordTag(E word)
public static WordTag valueOf(java.lang.String s)
public static WordTag valueOf(java.lang.String s, java.lang.String tagDivider)
public java.lang.String value()
public java.lang.String word()
HasWord
public void setValue(java.lang.String value)
public java.lang.String tag()
HasTag
public void setWord(java.lang.String word)
HasWord
public void setTag(java.lang.String tag)
HasTag
public java.lang.String toString()
toString()
method
causes a label to spill its guts. It should always return an
empty string rather than null
if there is no value.public java.lang.String toString(java.lang.String divider)
public void setFromString(java.lang.String wordTagString)
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
.setFromString
in interface Label
wordTagString
- The word that will go into the Word
public void setFromString(java.lang.String wordTagString, java.lang.String divider)
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public int compareTo(WordTag wordTag)
compareTo
in interface java.lang.Comparable<WordTag>
wordTag
- object to compare tothis
is greater than
obj
, 0 if equal, negative otherwise)public LabelFactory labelFactory()
TaggedWord
).
The factory returned is always the same one (a singleton).labelFactory
in interface Label
public static LabelFactory factory()
public void read(java.io.DataInputStream in)
public void save(java.io.DataOutputStream out)