Method Summary |
|
public boolean | createEmbedding(Language> embeddedLanguage, int startSkipLength, int endSkipLength) Create language embedding without joining of the embedded sections. |
public boolean | createEmbedding(Language> embeddedLanguage, int startSkipLength, int endSkipLength, boolean joinSections) Create language embedding described by the given parameters.
If the underying text input is mutable then this method should only be called
within a write lock over the text input.
Parameters: embeddedLanguage - non-null embedded language Parameters: startSkipLength - >=0 number of characters in an initial part of the tokenfor which the language embedding is defined that should be excludedfrom the embedded section. |
public TokenSequence> | embedded() Get embedded token sequence if the token
to which this token sequence is currently positioned
has a language embedding. |
public TokenSequence<ET> | embedded(Language<ET> embeddedLanguage) Get embedded token sequence if the token
to which this token sequence is currently positioned
has a language embedding. |
public int | index() Get an index of token to which (or before which) this TS is currently positioned.
Initially or after
TokenSequence.move(int) or
TokenSequence.moveIndex(int) token sequence is positioned between tokens:
Token[0] Token[1] ... |
public boolean | isEmpty() Check whether this TS contains zero tokens. |
public boolean | isValid() Check whether this token sequence is valid and can be iterated. |
public Language<T> | language() Get the language describing token ids
used by tokens in this token sequence. |
public LanguagePath | languagePath() Get the complete language path of the tokens contained
in this token sequence. |
public int | move(int offset) Move token sequence to be positioned between index-1
and index tokens where Token[index] either starts at offset
or "contains" the offset.
+----------+-----+----------------+--------------+------
| Token[0] | ... |
public void | moveEnd() Move the token sequence to be positioned behind the last token. |
public int | moveIndex(int index) Position token sequence between index-1
and index tokens.
TS will be positioned in the following way:
Token[0] ... |
public boolean | moveNext() Move to the next token in this token sequence.
The next token may not necessarily start at the offset where
the previous token ends (there may be gaps between tokens
caused by token filtering). |
public boolean | movePrevious() Move to a previous token in this token sequence.
The previous token may not necessarily end at the offset where
the previous token started (there may be gaps between tokens
caused by token filtering). |
public void | moveStart() Move the token sequence to be positioned before the first token. |
public int | offset() Get the offset of the current token in the underlying input. |
public Token<T> | offsetToken() Similar to
TokenSequence.token() but always returns a non-flyweight token
with the appropriate offset.
If the current token is flyweight then this method replaces it
with the corresponding non-flyweight token which it then returns.
Subsequent calls to
TokenSequence.token() will also return this non-flyweight token.
This method may be handy if the token instance is referenced in a standalone way
(e.g. |
public boolean | removeEmbedding(Language> embeddedLanguage) Remove previously created language embedding. |
public TokenSequence<T> | subSequence(int startOffset) Create sub sequence of this token sequence that only returns
tokens above the given offset.
Parameters: startOffset - only tokens satisfyingtokenStartOffset + tokenLength > startOffset will be present in the returned sequence. |
public TokenSequence<T> | subSequence(int startOffset, int endOffset) Create sub sequence of this token sequence that only returns
tokens between the given offsets.
Parameters: startOffset - only tokens satisfyingtokenStartOffset + tokenLength > startOffset will be present in the returned sequence. Parameters: endOffset - >=startOffset only tokens satisfyingtokenStartOffset < endOffset will be present in the returned sequence. |
public String | toString() |
public Token<T> | token() Get token to which this token sequence points to or null
if TS is positioned between tokens
(
TokenSequence.moveNext() or
TokenSequence.movePrevious() were not called yet).
A typical iteration usage:
TokenSequence ts = tokenHierarchy.tokenSequence();
// Possible positioning by ts.move(offset) or ts.moveIndex(index)
while (ts.moveNext()) {
Token t = ts.token();
if (t.id() == ...) { ... |
public int | tokenCount() Return total count of tokens in this sequence. |