Class DefaultVocabulary

  • All Implemented Interfaces:
    Vocabulary

    public class DefaultVocabulary
    extends java.lang.Object
    implements Vocabulary
    The default implementation of Vocabulary.
    • Constructor Detail

      • DefaultVocabulary

        public DefaultVocabulary​(java.util.List<java.lang.String> tokens)
        Creates a DefaultVocabulary object with the given list of tokens.
        Parameters:
        tokens - the List of tokens to build the vocabulary with
    • Method Detail

      • contains

        public boolean contains​(java.lang.String token)
        Check if the vocabulary contains a token.
        Specified by:
        contains in interface Vocabulary
        Parameters:
        token - String token to be checked
        Returns:
        whether this vocabulary contains the token
      • getToken

        public java.lang.String getToken​(long index)
        Returns the token corresponding to the given index.
        Specified by:
        getToken in interface Vocabulary
        Parameters:
        index - the index
        Returns:
        the token corresponding to the given index
      • getIndex

        public long getIndex​(java.lang.String token)
        Returns the index of the given token.
        Specified by:
        getIndex in interface Vocabulary
        Parameters:
        token - the token
        Returns:
        the index of the given token.
      • builder

        public static DefaultVocabulary.Builder builder()
        Creates a new builder to build a DefaultVocabulary.
        Returns:
        a new builder