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 WordTag

    java.lang.Object
      edu.stanford.nlp.ling.WordTag

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

    public class WordTag

extends Object
implements Label, HasWord, HasTag, Comparable<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.

The equality relation for WordTag is defined as identity of both word and tag. Note that this is different from `TaggedWord`, for which equality derives from `ValueLabel` and requires only identity of value.

Author:
  Roger Levy
See Also:
  Serialized Form

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)`
`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 wordTagString)` Sets a WordTag 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.
`static WordTag` | `valueOf(String s)`
`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

### WordTag

    public WordTag(String word,
                   String tag)

  Create a new `WordTag`.

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

### WordTag

    public WordTag(String word)

### WordTag

    public WordTag(E word)

### WordTag

    public WordTag()

### WordTag

    public WordTag(Label word,
                   Label tag)

  Create a new `WordTag` from a Label. The value of the Label corresponds to the word of the WordTag.

  Parameters:
    `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

### valueOf

    public static WordTag valueOf(String s)

### value

    public String value()

  Return a String representation of just the "main" value of this label.

  Specified by:
    `value` in interface `Label`
  Returns:
    the "value" of the label

### word

    public String word()

  Description copied from interface: `HasWord`
  Return the word value of the label (or null if none).

  Specified by:
    `word` in interface `HasWord`
  Returns:
    String the word value for the label

### setValue

    public void setValue(String value)

  Set the value for the label (if one is stored).

  Specified by:
    `setValue` in interface `Label`
  Parameters:
    `value` - - the value for the label

### 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

### setWord

    public void setWord(String word)

  Description copied from interface: `HasWord`
  Set the word value for the label (if one is stored).

  Specified by:
    `setWord` in interface `HasWord`
  Parameters:
    `word` - The word 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()

  Return a String representation of the label. For a multipart label, this will return all parts. The `toString()` method causes a label to spill its guts. It should always return an empty string rather than `null` if there is no value.

  Specified by:
    `toString` in interface `Label`
  Overrides:
    `toString` in class `Object`
  Returns:
    a text representation of the full label contents

### setFromString

    public void setFromString(String wordTagString)

  Sets a WordTag 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`
  Parameters:
    `wordTagString` - The word that will go into the `Word`

### equals

    public boolean equals(Object o)

  A WordTag is equal only to another WordTag with the same word and tag values.

  Overrides:
    `equals` in class `Object`

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `Object`

### compareTo

    public int compareTo(WordTag wordTag)

  Orders first by word, then by tag.

  Specified by:
    `compareTo` in interface `Comparable<WordTag>`
  Parameters:
    `wordTag` - object to compare to
  Returns:
    result (positive if `this` is greater than `obj`, 0 if equal, negative otherwise)

### 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`
  Returns:
    The label factory

### factory

    public static LabelFactory factory()

  Return a factory for this kind of label.

  Returns:
    The label factory

### 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

### read

    public void read(DataInputStream in)

### save

    public void save(DataOutputStream out)

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