edu.stanford.nlp.process
Class CoreLabelTokenFactory

java.lang.Object
  extended by edu.stanford.nlp.process.CoreLabelTokenFactory
All Implemented Interfaces:
CoreTokenFactory<CoreLabel>, LexedTokenFactory<CoreLabel>

public class CoreLabelTokenFactory
extends Object
implements CoreTokenFactory<CoreLabel>, LexedTokenFactory<CoreLabel>

Constructs CoreLabels from Strings optionally with beginning and ending (character after the end) offset positions in an original text. The makeToken method will put the token in the CurrentAnnotation AND TextAnnotation keys (2 places!), and optionally records begin and position after offsets in BeginPositionAnnotation and EndPositionAnnotation. If the tokens are built in PTBTokenizer with an "invertible" tokenizer, you will also get a BeforeAnnotation and for the last token an AfterAnnotation.You can also get an empty CoreLabel token

Author:
Anna Rafferty, Sonal Gupta (now implements CoreTokenFactory, you can make tokens using many options)

Constructor Summary
CoreLabelTokenFactory()
          Constructor for a new token factory which will add in the word, the "current" annotation, and the begin/end position annotations.
CoreLabelTokenFactory(boolean addIndices)
          Constructor that allows one to choose if index annotation indicating begin/end position will be included in the label
 
Method Summary
 CoreLabel makeToken()
           
 CoreLabel makeToken(CoreLabel labelToBeCopied)
           
 CoreLabel makeToken(String[] keys, String[] values)
           
 CoreLabel makeToken(String str, int begin, int length)
          Constructs a CoreLabel as a String with a corresponding BEGIN and END position.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CoreLabelTokenFactory

public CoreLabelTokenFactory()
Constructor for a new token factory which will add in the word, the "current" annotation, and the begin/end position annotations.


CoreLabelTokenFactory

public CoreLabelTokenFactory(boolean addIndices)
Constructor that allows one to choose if index annotation indicating begin/end position will be included in the label

Parameters:
addIndices - if true, begin and end position annotations will be included (this is the default)
Method Detail

makeToken

public CoreLabel makeToken(String str,
                           int begin,
                           int length)
Constructs a CoreLabel as a String with a corresponding BEGIN and END position. (Does not take substring).

Specified by:
makeToken in interface LexedTokenFactory<CoreLabel>
Parameters:
str - The String extracted by the lexer.
begin - The offset in the document of the first character in this string.
length - The number of characters the string takes up in the document.
Returns:
The token of type T.

makeToken

public CoreLabel makeToken()
Specified by:
makeToken in interface CoreTokenFactory<CoreLabel>

makeToken

public CoreLabel makeToken(String[] keys,
                           String[] values)
Specified by:
makeToken in interface CoreTokenFactory<CoreLabel>

makeToken

public CoreLabel makeToken(CoreLabel labelToBeCopied)
Specified by:
makeToken in interface CoreTokenFactory<CoreLabel>


Stanford NLP Group