edu.stanford.nlp.ling
Class LabeledWord

java.lang.Object
  extended by edu.stanford.nlp.ling.ValueLabel
      extended by edu.stanford.nlp.ling.StringLabel
          extended by edu.stanford.nlp.ling.Word
              extended by edu.stanford.nlp.ling.LabeledWord
All Implemented Interfaces:
HasOffset, HasWord, Label, java.io.Serializable, java.lang.Comparable<ValueLabel>

public class LabeledWord
extends Word

A LabeledWord object contains a word and its tag. The value() of a TaggedWord is the Word. The tag is, and is a Label instead of a String

See Also:
Serialized Form

Field Summary
 
Fields inherited from class edu.stanford.nlp.ling.Word
EMPTY, EMPTYSTRING
 
Constructor Summary
LabeledWord()
          Create a new TaggedWord.
LabeledWord(Label word, Label tag)
           
LabeledWord(java.lang.String word)
          Create a new TaggedWord.
LabeledWord(java.lang.String word, Label 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).
static void setDivider(java.lang.String divider)
          Set the String (usually just a single character) used to mark the separation between the word and the tag.
 void setTag(Label tag)
           
 Label tag()
           
 java.lang.String toString()
          Return a string representation of the label.
 
Methods inherited from class edu.stanford.nlp.ling.Word
setWord, word
 
Methods inherited from class edu.stanford.nlp.ling.StringLabel
beginPosition, endPosition, setBeginPosition, setEndPosition, setFromString, setValue, value
 
Methods inherited from class edu.stanford.nlp.ling.ValueLabel
compareTo, equals, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LabeledWord

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


LabeledWord

public LabeledWord(java.lang.String word)
Create a new TaggedWord.

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

LabeledWord

public LabeledWord(java.lang.String word,
                   Label tag)
Create a new TaggedWord.

Parameters:
word - The word
tag - The tag

LabeledWord

public LabeledWord(Label word,
                   Label tag)
Method Detail

tag

public Label tag()

setTag

public void setTag(Label tag)

toString

public java.lang.String toString()
Description copied from class: ValueLabel
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 StringLabel
Returns:
The string representation

setDivider

public static void setDivider(java.lang.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

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