|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.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.
TaggedWord should be considered deprecated and the use of WordTag
is preferable.
Constructor Summary | |
---|---|
WordTag()
|
|
WordTag(Label 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 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 ). |
void |
read(DataInputStream in)
|
void |
save(DataOutputStream out)
|
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). |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public WordTag(String word)
public WordTag(Label word)
public WordTag()
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(Label word, Label tag)
WordTag
from a Label. The value of
the Label corresponds to the word of the WordTag.
word
- This word is passed to the supertype constructortag
- The value()
of this label is set as the
tag of this LabelMethod Detail |
---|
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 void setFromString(String taggedWord)
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
taggedWord
- The word that will go into the Word
public boolean equals(Object obj)
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 static void setDivider(String divider)
TaggedWord
via the toString()
method, and when reading in a TaggedWord
via the
setFromString()
method.
Unless altered using this method, the default is "/".
divider
- The String between words and tagspublic 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 |