edu.stanford.nlp.ling
Class WordLemmaTag

java.lang.Object
  extended by edu.stanford.nlp.ling.WordLemmaTag
All Implemented Interfaces:
HasTag, HasWord, Label, Serializable, Comparable<WordLemmaTag>

public class WordLemmaTag
extends Object
implements Label, Comparable<WordLemmaTag>, HasWord, HasTag

/** A WordLemmaTag corresponds to a pair of a tagged (e.g., for part of speech) word and its lemma. WordLemmaTag is implemented with String-valued word, lemma and tag. It implements the Label interface; the value() method for that interface corresponds to the word of the WordLemmaTag.

The equality relation for WordLemmaTag is defined as identity of word, lemma and tag.

Author:
Marie-Catherine de Marneffe
See Also:
Serialized Form

Constructor Summary
WordLemmaTag()
           
WordLemmaTag(Label word)
           
WordLemmaTag(Label word, Label tag)
          Create a new WordLemmaTag from a Label.
WordLemmaTag(String word)
           
WordLemmaTag(String word, String tag)
          Create a new WordLemmaTag.
WordLemmaTag(String word, String lemma, String tag)
          Create a new WordLemmaTag.
 
Method Summary
 int compareTo(WordLemmaTag wordLemmaTag)
          Orders first by word, then by lemma, then by tag.
 boolean equals(Object obj)
          Equality is satisfied only if the compared object is a WordLemmaTag and has String-equal word, lemma and tag fields.
 LabelFactory labelFactory()
          Return a factory for this kind of label (i.e., TaggedWord).
 String lemma()
           
static void main(String[] args)
           
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 labelStr)
          The String is divided according to the divider character (usually, "/").
 void setLemma(String lemma)
           
 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.
 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, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WordLemmaTag

public WordLemmaTag(String word)

WordLemmaTag

public WordLemmaTag(Label word)

WordLemmaTag

public WordLemmaTag()

WordLemmaTag

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

Parameters:
word - This word is set as the word of this Label
tag - The value() of this Label is set as the tag of this Label

WordLemmaTag

public WordLemmaTag(String word,
                    String lemma,
                    String tag)
Create a new WordLemmaTag.

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

WordLemmaTag

public WordLemmaTag(Label word,
                    Label tag)
Create a new WordLemmaTag from a Label. The value of the Label corresponds to the word of the WordLemmaTag.

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

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.

Specified by:
setValue in interface Label
Parameters:
value - the 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

setLemma

public void setLemma(String lemma)

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

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

lemma

public String lemma()

toString

public String toString()
Return a String representation of the Label. For a multipart Label, this will return all parts.

Specified by:
toString in interface Label
Overrides:
toString in class Object
Returns:
a text representation of the full label contents: word/lemma/tag

setFromString

public void setFromString(String labelStr)
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 lemma and tag are null. We assume that if only one divider character is found, word and tag are presents in the String, and lemma will be computed.

Specified by:
setFromString in interface Label
Parameters:
labelStr - The word that will go into the WordLemmaTag

equals

public boolean equals(Object obj)
Equality is satisfied only if the compared object is a WordLemmaTag and has String-equal word, lemma and tag fields.

Overrides:
equals in class Object

compareTo

public int compareTo(WordLemmaTag wordLemmaTag)
Orders first by word, then by lemma, then by tag.

Specified by:
compareTo in interface Comparable<WordLemmaTag>
Parameters:
wordLemmaTag - 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

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, tags (and lemmas)

main

public static void main(String[] args)


Stanford NLP Group