Class Token

java.lang.Object
org.tribuo.util.tokens.Token

public class Token extends Object
A single token extracted from a String.

Tokens are immutable.

  • Field Details

  • Constructor Details

    • Token

      public Token(String text, int start, int end)
      Constructs a token.
      Parameters:
      text - should be equivalent to the substring of the original tokenized text for the given character offsets start and end
      start - the starting offset of the token
      end - the ending offset of the token (exclusive or inclusive?)
    • Token

      public Token(String text, int start, int end, Token.TokenType type)
      Constructs a token.
      Parameters:
      text - should be equivalent to the substring of the original tokenized text for the given character offsets start and end
      start - the starting offset of the token
      end - the ending offset of the token (exclusive or inclusive?)
      type - the type of the token
  • Method Details

    • length

      public int length()
      The number of characters in this token.
      Returns:
      The number of characters.
    • toString

      public String toString()
      Overrides:
      toString in class Object