edu.stanford.nlp.ling
Class WordTagFactory

java.lang.Object
  extended by edu.stanford.nlp.ling.WordTagFactory
All Implemented Interfaces:
LabelFactory

public class WordTagFactory
extends Object
implements LabelFactory

A WordTagFactory acts as a factory for creating objects of class WordTag. Note that WordTag is a replacement for (now deprecated) TaggedWord, which has a less stringent equality condition.

Author:
Christopher Manning, Roger Levy

Constructor Summary
WordTagFactory()
          Create a new WordTagFactory.
WordTagFactory(char divider)
          Create a new WordTagFactory.
 
Method Summary
 Label newLabel(Label oldLabel)
          Create a new WordTag Label, where the label is formed from the Label object passed in.
 Label newLabel(String labelStr)
          Make a new label with this String as the value (word).
 Label newLabel(String labelStr, int options)
          Make a new label with this String as a value component.
 Label newLabelFromString(String word)
          Create a new word, where the label is formed from the String passed in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WordTagFactory

public WordTagFactory()
Create a new WordTagFactory. The divider will be taken as '/'.


WordTagFactory

public WordTagFactory(char divider)
Create a new WordTagFactory.

Parameters:
divider - This character will be used in calls to the one argument version of newLabel(), to divide the word from the tag. Stuff after the last instance of this character will become the tag, and stuff before it will become the label.
Method Detail

newLabel

public Label newLabel(String labelStr)
Make a new label with this String as the value (word). Any other fields of the label would normally be null.

Specified by:
newLabel in interface LabelFactory
Parameters:
labelStr - The String that will be used for value
Returns:
The new WordTag (tag will be null)

newLabel

public Label newLabel(String labelStr,
                      int options)
Make a new label with this String as a value component. Any other fields of the label would normally be null.

Specified by:
newLabel in interface LabelFactory
Parameters:
labelStr - The String that will be used for value
options - what to make (use labelStr as word or tag)
Returns:
The new WordTag (tag or word will be null)

newLabelFromString

public Label newLabelFromString(String word)
Create a new word, where the label is formed from 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:
newLabelFromString in interface LabelFactory
Parameters:
word - The word that will go into the Word
Returns:
The new WordTag

newLabel

public Label newLabel(Label oldLabel)
Create a new WordTag Label, where the label is formed from the Label object passed in. Depending on what fields each label has, other things will be null.

Specified by:
newLabel in interface LabelFactory
Parameters:
oldLabel - The Label that the new label is being created from
Returns:
a new label of a particular type


Stanford NLP Group