net.java.sen.dictionary
Class Token

java.lang.Object
  extended by net.java.sen.dictionary.Token

public class Token
extends Object

A single token from an analysed sentence

Thread Safety: Objects of this class are NOT thread safe and should not be accessed simultaneously by multiple threads.

CAUTION: Morphemes are implemented as lazy proxies onto a Dictionary, and care should be taken not to access the same Dictionary from multiple threads. Once any member of a Morpheme has been read, its link to the Dictionary is broken and this restriction is relaxed


Constructor Summary
Token()
          Creates a blank Token
Token(String surface, int cost, int start, int length, Morpheme morpheme)
          Creates a Token with explicit parameters
Token(String surface, Node node)
          Creates a Token from a Node
 
Method Summary
 int end()
          Gets the end of the character range of this Token within the underlying sentence
 boolean equals(Object object)
           
 int getCost()
          Gets the Viterbi cost of this Token
 int getLength()
          Gets the length of the character range of this Token within the underlying sentence
 Morpheme getMorpheme()
          Gets the morpheme data for this Token
 int getStart()
          Gets the start of the character range of this Token within the underlying sentence
 String getSurface()
          Gets the character range of this Token within the underlying sentence
 boolean isSentenceStart()
          Returns whether or not this Token begins a new sentence.
 void setCost(int cost)
          Sets the Viterbi cost of this Token
 void setLength(int length)
          Sets the length of the character range of this Token within the underlying sentence
 void setMorpheme(Morpheme morpheme)
          Sets the morpheme data for this Token
 void setSentenceStart(boolean sentenceStart)
          Sets whether or not this token begins a new sentence.
 void setStart(int start)
          Sets the start of the character range of this Token within the underlying sentence
 void setSurface(String surface)
          Sets the character range of this Token within the underlying sentence
 String toString()
          Returns the character range of this Token within the underlying sentence
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Token

public Token(String surface,
             Node node)
Creates a Token from a Node

Parameters:
surface - The underlying sentence string
node - The Node to create from

Token

public Token(String surface,
             int cost,
             int start,
             int length,
             Morpheme morpheme)
Creates a Token with explicit parameters

Parameters:
surface - The character range within the underlying sentence
cost - The Viterbi cost
start - The start of the character range within the underlying sentence
length - The length of the character range within the underlying sentence
morpheme - The morpheme data

Token

public Token()
Creates a blank Token

Method Detail

isSentenceStart

public boolean isSentenceStart()
Returns whether or not this Token begins a new sentence.


setSentenceStart

public void setSentenceStart(boolean sentenceStart)
Sets whether or not this token begins a new sentence.


getStart

public int getStart()
Gets the start of the character range of this Token within the underlying sentence

Returns:
The start of the character range of this Token within the underlying sentence

setStart

public void setStart(int start)
Sets the start of the character range of this Token within the underlying sentence

Parameters:
start - The start of the character range of this Token within the underlying sentence

getLength

public int getLength()
Gets the length of the character range of this Token within the underlying sentence

Returns:
The length of the character range of this Token within the underlying sentence

setLength

public void setLength(int length)
Sets the length of the character range of this Token within the underlying sentence

Parameters:
length - The length of the character range of this Token within the underlying sentence

getSurface

public String getSurface()
Gets the character range of this Token within the underlying sentence

Returns:
The character range of this Token within the underlying sentence

setSurface

public void setSurface(String surface)
Sets the character range of this Token within the underlying sentence

Parameters:
surface - The character range of this Token within the underlying sentence

getCost

public int getCost()
Gets the Viterbi cost of this Token

Returns:
The Viterbi cost of this Token

setCost

public void setCost(int cost)
Sets the Viterbi cost of this Token

Parameters:
cost - The Viterbi cost of this Token

getMorpheme

public Morpheme getMorpheme()
Gets the morpheme data for this Token

Returns:
The morpheme data for this Token

setMorpheme

public void setMorpheme(Morpheme morpheme)
Sets the morpheme data for this Token

Parameters:
morpheme - new Morpheme for this Token

end

public int end()
Gets the end of the character range of this Token within the underlying sentence

Returns:
The end of the character range of this Token within the underlying sentence

equals

public boolean equals(Object object)
Overrides:
equals in class Object

toString

public String toString()
Returns the character range of this Token within the underlying sentence

Overrides:
toString in class Object
Returns:
The character range of this Token within the underlying sentence


Copyright © 2012. All Rights Reserved.