public class Token extends java.lang.Object implements AbstractToken
CoreLabel
-like interface,
though many of the methods are not supported (most notably, the setters).Modifier and Type | Field and Description |
---|---|
int |
index
The index of this token in the underlying sentence.
|
Sentence |
sentence
The underlying sentence supplying the fields for this token.
|
Constructor and Description |
---|
Token(Sentence sentence,
int index)
Create a wrapper for a token, given a sentence and an index in the sentence
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
after()
Return the whitespace String after the word.
|
java.lang.String |
before() |
int |
beginPosition()
Return the beginning char offset of the label (or -1 if none).
|
int |
characterOffsetBegin() |
int |
characterOffsetEnd() |
java.lang.String |
docID() |
int |
endPosition()
Return the ending char offset of the label (or -1 if none).
|
java.util.Optional<java.lang.Integer> |
governor() |
java.util.Optional<java.lang.String> |
incomingDependencyLabel() |
int |
index() |
java.lang.String |
lemma()
Return the lemma value of the label (or null if none).
|
java.lang.String |
ner()
Return the named entity class of the label (or null if none).
|
java.lang.String |
nerTag() |
Token |
next()
The next token in the sentence.
|
java.lang.String |
originalText()
Return the String which is the original character sequence of the token.
|
java.lang.String |
posTag() |
Token |
previous()
The previous token in the sentence.
|
int |
sentIndex() |
void |
setAfter(java.lang.String after)
Set the whitespace String after the word.
|
void |
setBefore(java.lang.String before)
Set the whitespace String before the word.
|
void |
setBeginPosition(int beginPos)
Set the beginning character offset for the label.
|
void |
setDocID(java.lang.String docID) |
void |
setEndPosition(int endPos)
Set the ending character offset of the label (or -1 if none).
|
void |
setIndex(int index) |
void |
setLemma(java.lang.String lemma)
Set the lemma value for the label (if one is stored).
|
void |
setNER(java.lang.String ner)
Set the named entity class of the label.
|
void |
setOriginalText(java.lang.String originalText)
Set the String which is the original character sequence of the token.
|
void |
setSentIndex(int sentIndex) |
void |
setTag(java.lang.String tag)
Set the tag value for the label (if one is stored).
|
void |
setWord(java.lang.String word)
Set the word value for the label (if one is stored).
|
java.lang.String |
tag()
Return the tag value of the label (or null if none).
|
java.lang.String |
word()
Return the word value of the label (or null if none).
|
public final Sentence sentence
public final int index
public Token(Sentence sentence, int index)
public Token previous()
public Token next()
public java.lang.String word()
HasWord
word
in interface HasWord
Sentence.word(int)
public void setWord(java.lang.String word)
HasWord
public java.lang.String originalText()
HasContext
originalText
in interface HasContext
originalText
in interface HasOriginalText
Sentence.originalText(int)
public void setOriginalText(java.lang.String originalText)
HasContext
setOriginalText
in interface HasContext
setOriginalText
in interface HasOriginalText
originalText
- The original character sequence of the tokenpublic java.lang.String lemma()
HasLemma
lemma
in interface HasLemma
Sentence.lemma(int)
public void setLemma(java.lang.String lemma)
HasLemma
public java.lang.String ner()
HasNER
ner
in interface HasNER
Sentence.nerTag(int)
public void setNER(java.lang.String ner)
HasNER
public java.lang.String nerTag()
Sentence.nerTag(int)
public java.lang.String tag()
HasTag
tag
in interface HasTag
Sentence.posTag(int)
public void setTag(java.lang.String tag)
HasTag
public java.lang.String posTag()
Sentence.posTag(int)
public java.util.Optional<java.lang.Integer> governor()
Sentence.governor(int)
public int characterOffsetBegin()
Sentence.characterOffsetBegin(int)
public int characterOffsetEnd()
Sentence.characterOffsetEnd(int)
public java.lang.String before()
before
in interface HasContext
Sentence.before(int)
public void setBefore(java.lang.String before)
HasContext
setBefore
in interface HasContext
before
- the whitespace String before the wordpublic java.lang.String after()
HasContext
after
in interface HasContext
Sentence.after(int)
public void setAfter(java.lang.String after)
HasContext
setAfter
in interface HasContext
after
- The whitespace String after the wordpublic java.util.Optional<java.lang.String> incomingDependencyLabel()
Sentence.incomingDependencyLabel(int)
public void setSentIndex(int sentIndex)
setSentIndex
in interface HasIndex
public int beginPosition()
HasOffset
beginPosition
in interface HasOffset
public void setBeginPosition(int beginPos)
HasOffset
setBeginPosition
in interface HasOffset
beginPos
- The beginning positionpublic int endPosition()
HasOffset
endPosition
in interface HasOffset
public void setEndPosition(int endPos)
HasOffset
setEndPosition
in interface HasOffset
endPos
- The end character offset for the label