edu.stanford.nlp.trees
Class TaggedWord

java.lang.Object
  |
  +--edu.stanford.nlp.trees.AbstractLabel
        |
        +--edu.stanford.nlp.trees.StringLabel
              |
              +--edu.stanford.nlp.trees.Word
                    |
                    +--edu.stanford.nlp.trees.TaggedWord
All Implemented Interfaces:
Comparable, HasTag, HasWord, Label
Direct Known Subclasses:
TypedTaggedWord, WeightedFollowedTaggedWord

public class TaggedWord
extends Word
implements HasTag

A TaggedWord object contains a word and its tag. The value() of a TaggedWord is the Word. The tag is secondary.


Field Summary
 
Fields inherited from class edu.stanford.nlp.trees.Word
EMPTY, EMPTYSTRING
 
Constructor Summary
TaggedWord()
          Create a new TaggedWord.
TaggedWord(Label oldLabel)
          Create a new TaggedWord.
TaggedWord(Label word, Label tag)
          Create a new TaggedWord.
TaggedWord(String word)
          Create a new TaggedWord.
TaggedWord(String word, String tag)
          Create a new TaggedWord.
 
Method Summary
static LabelFactory factory()
          Return a factory for this kind of label.
 LabelFactory labelFactory()
          Return a factory for this kind of label (i.e., TaggedWord).
 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).
 String tag()
          Return the tag value of the label (or null if none).
 String toString()
          Return a string representation of the label.
 
Methods inherited from class edu.stanford.nlp.trees.Word
setWord, word
 
Methods inherited from class edu.stanford.nlp.trees.StringLabel
setValue, value
 
Methods inherited from class edu.stanford.nlp.trees.AbstractLabel
compareTo, equals, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TaggedWord

public TaggedWord()
Create a new TaggedWord. It will have null for its content fields.


TaggedWord

public TaggedWord(String word)
Create a new TaggedWord.

Parameters:
word - The word, which will have a null tag

TaggedWord

public TaggedWord(String word,
                  String tag)
Create a new TaggedWord.

Parameters:
word - The word
tag - The tag

TaggedWord

public TaggedWord(Label oldLabel)
Create a new TaggedWord.

Parameters:
oldLabel - A Label. If it implements the HasWord and/or HasTag interface, then the corresponding value will be set

TaggedWord

public TaggedWord(Label word,
                  Label tag)
Create a new TaggedWord.

Parameters:
word - This word is passed to the supertype constructor
tag - The value() of this label is set as the tag of this Label
Method Detail

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

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()
Description copied from class: AbstractLabel
Return a string representation of the label. This will just be the value() if it is non-null, and the empty string otherwise.

Specified by:
toString in interface Label
Overrides:
toString in class AbstractLabel
Returns:
the string representation

setFromString

public void setFromString(String taggedWord)
Sets a TaggedWord from decoding the String passed in. The String is divided according to the divider character ("/"). 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
Overrides:
setFromString in class StringLabel
Parameters:
taggedWord - The word that will go into the Word

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
Overrides:
labelFactory in class Word
Returns:
The label factory

factory

public static LabelFactory factory()
Return a factory for this kind of label.

Returns:
The label factory


Stanford NLP Group