|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.nlp.ling.WordTag
public class WordTag
A WordTag corresponds to a tagged (e.g., for part of speech) word
and is implemented with String-valued word and tag. It implements
the Label interface; the value()
method for that
interface corresponds to the word of the WordTag.
TaggedWord
, for which equality derives from
ValueLabel
and requires only identity of value.
Constructor Summary | |
---|---|
WordTag()
|
|
WordTag(E word)
|
|
WordTag(Label word,
Label tag)
Create a new WordTag from a Label. |
|
WordTag(String word)
|
|
WordTag(String word,
String tag)
Create a new WordTag . |
Method Summary | |
---|---|
int |
compareTo(WordTag wordTag)
Orders first by word, then by tag. |
boolean |
equals(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(DataInputStream in)
|
void |
save(DataOutputStream out)
|
void |
setFromString(String wordTagString)
Sets a WordTag from decoding the String passed in. |
void |
setFromString(String wordTagString,
String divider)
|
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 |
toString(String divider)
|
String |
value()
Return a String representation of just the "main" value of this label. |
static WordTag |
valueOf(String s)
|
static WordTag |
valueOf(String s,
String tagDivider)
|
String |
word()
Return the word value of the label (or null if none). |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public WordTag(String word, 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(String word)
public WordTag(E word)
public WordTag()
public WordTag(Label word, Label tag)
WordTag
from a Label. The value of
the Label corresponds to the word of the WordTag.
word
- The value()
of this label is set as the
word of the WordTag
tag
- The value()
of this label is set as the
tag of the WordTag
Method Detail |
---|
public static WordTag valueOf(String s)
public static WordTag valueOf(String s, String tagDivider)
public String value()
value
in interface Label
public String word()
HasWord
word
in interface HasWord
public void setValue(String value)
setValue
in interface Label
value
- - the value for the labelpublic String tag()
HasTag
tag
in interface HasTag
public void setWord(String word)
HasWord
setWord
in interface HasWord
word
- The word value for the labelpublic void setTag(String tag)
HasTag
setTag
in interface HasTag
tag
- The tag value for the labelpublic 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.
toString
in interface Label
toString
in class Object
public String toString(String divider)
public void setFromString(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(String wordTagString, String divider)
public boolean equals(Object o)
equals
in class Object
public int hashCode()
hashCode
in class Object
public int compareTo(WordTag wordTag)
compareTo
in interface Comparable<WordTag>
wordTag
- object to compare to
this
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(DataInputStream in)
public void save(DataOutputStream out)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |