Package banner.types

Class Token

  • All Implemented Interfaces:
    Comparable<Token>

    public class Token
    extends Object
    implements Comparable<Token>
    Represents a single token of text. Note that the token does not know what Mention it is a part of, if any.
    Author:
    Bob
    • Constructor Detail

      • Token

        public Token​(Sentence sentence,
                     int start,
                     int end)
        The token is from character start to character end - 1
        Parameters:
        sentence -
        start -
        end -
    • Method Detail

      • getText

        public String getText()
        Returns:
        The text for this token
      • getStart

        public int getStart()
        Returns:
        The start index for this token, inclusive
      • getEnd

        public int getEnd()
        Returns:
        The end index for this token, exclusive
      • getStart

        public int getStart​(boolean ignoreWhitespace)
        Returns:
        The start index for this token, inclusive
      • getEnd

        public int getEnd​(boolean ignoreWhitespace)
        Returns:
        The end index for this token, exclusive
      • contains

        public boolean contains​(int index)
      • length

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

        public int hashCode()
        Overrides:
        hashCode in class Object