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()
HasWordword in interface HasWordSentence.word(int)public void setWord(java.lang.String word)
HasWordpublic java.lang.String originalText()
HasContextoriginalText in interface HasContextoriginalText in interface HasOriginalTextSentence.originalText(int)public void setOriginalText(java.lang.String originalText)
HasContextsetOriginalText in interface HasContextsetOriginalText in interface HasOriginalTextoriginalText - The original character sequence of the tokenpublic java.lang.String lemma()
HasLemmalemma in interface HasLemmaSentence.lemma(int)public void setLemma(java.lang.String lemma)
HasLemmapublic java.lang.String ner()
HasNERner in interface HasNERSentence.nerTag(int)public void setNER(java.lang.String ner)
HasNERpublic java.lang.String nerTag()
Sentence.nerTag(int)public java.lang.String tag()
HasTagtag in interface HasTagSentence.posTag(int)public void setTag(java.lang.String tag)
HasTagpublic 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 HasContextSentence.before(int)public void setBefore(java.lang.String before)
HasContextsetBefore in interface HasContextbefore - the whitespace String before the wordpublic java.lang.String after()
HasContextafter in interface HasContextSentence.after(int)public void setAfter(java.lang.String after)
HasContextsetAfter in interface HasContextafter - The whitespace String after the wordpublic java.util.Optional<java.lang.String> incomingDependencyLabel()
Sentence.incomingDependencyLabel(int)public void setSentIndex(int sentIndex)
setSentIndex in interface HasIndexpublic int beginPosition()
HasOffsetbeginPosition in interface HasOffsetpublic void setBeginPosition(int beginPos)
HasOffsetsetBeginPosition in interface HasOffsetbeginPos - The beginning positionpublic int endPosition()
HasOffsetendPosition in interface HasOffsetpublic void setEndPosition(int endPos)
HasOffsetsetEndPosition in interface HasOffsetendPos - The end character offset for the label