Class Token.Builder

Enclosing class:
Token

public static class Token.Builder extends Attribute.Builder<Token,Token.Builder>
Builder for tokens.
  • Constructor Details

    • Builder

      public Builder(int startOffset, int endOffset, String text)
      Constructs a builder from the required properties.
      Parameters:
      startOffset - the start offset in characters
      endOffset - the end offset in characters
      text - the text of the token
    • Builder

      public Builder(Token toCopy)
      Constructs a builder from the values of an existing token.
      Parameters:
      toCopy - existing token to copy
  • Method Details

    • text

      public Token.Builder text(String text)
      Specifies the text.
      Parameters:
      text - the text
      Returns:
      this
    • addNormalized

      public Token.Builder addNormalized(String normalized)
      Adds a normalized form.
      Parameters:
      normalized - the normalized form
      Returns:
      this
    • normalized

      public Token.Builder normalized(List<String> normalized)
      Sets the list of normalized forms.
      Parameters:
      normalized - the normalized token forms.
      Returns:
      this.
    • source

      public Token.Builder source(String source)
      Specifies the source of this token.
      Parameters:
      source - the source
      Returns:
      this
    • addAnalysis

      public Token.Builder addAnalysis(MorphoAnalysis analysis)
      Adds an analysis.
      Parameters:
      analysis - the analysis
      Returns:
      this
    • analyses

      public Token.Builder analyses(List<MorphoAnalysis> analyses)
      Sets the list of morphological analyses.
      Parameters:
      analyses - the analyses.
      Returns:
      this.
    • build

      public Token build()
      Creates a new immutable Token object from the current state of the builder.
      Returns:
      the new token
    • getThis

      protected Token.Builder getThis()
      Specified by:
      getThis in class Attribute.Builder<Token,Token.Builder>