Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.stanford.nlp.ling
Class TaggedWord

    java.lang.Object
      edu.stanford.nlp.ling.ValueLabel
          edu.stanford.nlp.ling.StringLabel
              edu.stanford.nlp.ling.Word
                  edu.stanford.nlp.ling.TaggedWord

All Implemented Interfaces:
  HasOffset, HasTag, HasWord, Label, Serializable, Comparable<ValueLabel>

    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.

Author:
  Christopher Manning
See Also:
  Serialized Form

Field Summary

Fields inherited from class edu.stanford.nlp.ling.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`).
`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).
`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.ling.Word
`setWord, word`

Methods inherited from class edu.stanford.nlp.ling.StringLabel
`beginPosition, endPosition, setBeginPosition, setEndPosition, 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

### 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: `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(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

### setFromString

    public void setFromString(String taggedWord)

  Sets a TaggedWord from decoding the `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`.

  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

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Stanford NLP Group