Class Annotator.Builder<F,T extends Comparable<T>>

java.lang.Object
org.coordinatekit.crf.annotator.Annotator.Builder<F,T>
Type Parameters:
F - the feature type carried by the tagger and the per-token entries
T - the tag type
Enclosing class:
Annotator<F,T extends Comparable<T>>

public static final class Annotator.Builder<F,T extends Comparable<T>> extends Object
Builder for Annotator.

tagProvider(TagProvider), taggingInterface(TaggingInterface), and terminal(Terminal) are required. At least one of tokenizer or tagger must be set: a tagger supplies both the tokenization and tag suggestions, while a tokenizer alone drives the manual-only path — see the class-level Javadoc.

  • Method Details

    • build

      public Annotator<F,T> build()
      Builds the annotator.
      Returns:
      a new Annotator
      Throws:
      IllegalStateException - if tagProvider, taggingInterface, or terminal have not been set; if neither a tokenizer nor a tagger has been set; or if the supplied TagProvider.tags() set is empty
    • featureExtractor

      public Annotator.Builder<F,T> featureExtractor(@Nullable FeatureExtractor<F> featureExtractor)
      Sets the feature extractor used to compute the key display features shown by the feature view of the tagging interface. May be null; when null, the key-feature view is not offered (the all-features view may still be, when a verbose source applies). The extracted features are presentational only — they have no effect on tagging or training output.
      Parameters:
      featureExtractor - the display feature extractor, or null to disable the feature display
      Returns:
      this builder
    • tagger

      public Annotator.Builder<F,T> tagger(@Nullable CrfTagger<F,T> tagger)
      Sets the CRF tagger used to suggest tags for each input line. May be null. When present the tagger is the authoritative source of tokens and excluded runs — its tokenization is used directly and its suggestions are always shown — and the tokenizer(Tokenizer) becomes optional. When absent the tokenizer supplies the tokenization instead.
      Parameters:
      tagger - the tagger, or null to run without tag suggestions
      Returns:
      this builder
    • tagProvider

      public Annotator.Builder<F,T> tagProvider(TagProvider<T> tagProvider)
      Sets the tag provider, whose TagProvider.tags() set defines the tag space.
      Parameters:
      tagProvider - the tag provider
      Returns:
      this builder
    • taggingInterface

      public Annotator.Builder<F,T> taggingInterface(TaggingInterface<F,T> taggingInterface)
      Sets the tagging interface used to present each sequence to the user.
      Parameters:
      taggingInterface - the tagging interface
      Returns:
      this builder
    • terminal

      public Annotator.Builder<F,T> terminal(org.jline.terminal.Terminal terminal)
      Sets the JLine terminal used to emit the one-line resume message at session start. Ownership is not transferred; the caller is responsible for closing it.
      Parameters:
      terminal - the terminal
      Returns:
      this builder
    • tokenizer

      public Annotator.Builder<F,T> tokenizer(Tokenizer tokenizer)
      Sets the tokenizer used to split every input line into tokens and excluded runs. Required only when no tagger is configured; when a tagger is present it supplies the tokenization and this tokenizer is unused.
      Parameters:
      tokenizer - the tokenizer
      Returns:
      this builder
    • verboseFeatureExtractor

      public Annotator.Builder<F,T> verboseFeatureExtractor(@Nullable FeatureExtractor<F> verboseFeatureExtractor)
      Sets the feature extractor used to compute the verbose display features shown only by the all-features view of the tagging interface. May be null; when null and a tagger is configured, the all-features view falls back to the tagger's embedded features which are the features the model actually saw. Setting this extractor overrides that fallback. The extracted features are presentational only and have no effect on tagging or training output.
      Parameters:
      verboseFeatureExtractor - the verbose display feature extractor, or null to use the tagger fallback (or no verbose display)
      Returns:
      this builder