Class AnnotatorModels

java.lang.Object
org.coordinatekit.crf.annotator.AnnotatorModels

public final class AnnotatorModels extends Object
Factory for the public value types in the ui package.

Each public interface in this package (AnnotatorSequence, AnnotatorToken, TaggingResult) is paired with a private record implementation here and a static factory method that constructs and validates instances. Callers should statically import the factory methods.

  • Method Details

    • annotatorSequence

      public static <F, T extends Comparable<T>> AnnotatorSequence<F,T> annotatorSequence(int sequenceNumber, int totalSequences, Sequence<TaggedPositionedToken<F,T>> taggedSequence)
      Creates an AnnotatorSequence from a tagger's output, with no display features.

      Equivalent to annotatorSequence(sequenceNumber, totalSequences, taggedSequence, null, null).

      Type Parameters:
      F - the feature type
      T - the tag type
      Parameters:
      sequenceNumber - the 1-based position of this sequence within the overall annotation batch
      totalSequences - the total number of sequences in the overall annotation batch
      taggedSequence - the tagger's output for the sequence
      Returns:
      a new annotator sequence
      Throws:
      IllegalArgumentException - if sequenceNumber < 1 or totalSequences < sequenceNumber
    • annotatorSequence

      public static <F, T extends Comparable<T>> AnnotatorSequence<F,T> annotatorSequence(int sequenceNumber, int totalSequences, List<String> tokens, TagProvider<T> tagProvider)
      Creates an AnnotatorSequence for the no-tagger path, with no display features.

      Equivalent to annotatorSequence(sequenceNumber, totalSequences, tokens, tagProvider, null, null).

      Type Parameters:
      F - the feature type
      T - the tag type
      Parameters:
      sequenceNumber - the 1-based position of this sequence within the overall annotation batch
      totalSequences - the total number of sequences in the overall annotation batch
      tokens - the tokens of the sequence
      tagProvider - the tag provider, whose tags set defines the tag space offered on the edit screen
      Returns:
      a new annotator sequence
      Throws:
      IllegalArgumentException - if sequenceNumber < 1, totalSequences < sequenceNumber, tokens is empty, or tagProvider.tags() is empty
    • annotatorSequence

      public static <F, T extends Comparable<T>> AnnotatorSequence<F,T> annotatorSequence(int sequenceNumber, int totalSequences, Sequence<TaggedPositionedToken<F,T>> taggedSequence, @Nullable List<Set<F>> features, @Nullable List<Set<F>> verboseFeatures)
      Creates an AnnotatorSequence from a tagger's output, with optional display features and no probability function.

      Equivalent to annotatorSequence(sequenceNumber, totalSequences, taggedSequence, features, verboseFeatures, null).

      Type Parameters:
      F - the feature type
      T - the tag type
      Parameters:
      sequenceNumber - the 1-based position of this sequence within the overall annotation batch
      totalSequences - the total number of sequences in the overall annotation batch
      taggedSequence - the tagger's output for the sequence
      features - the per-token key display features, or null when not configured
      verboseFeatures - the per-token verbose display features, or null when not configured
      Returns:
      a new annotator sequence
      Throws:
      IllegalArgumentException - if sequenceNumber < 1, totalSequences < sequenceNumber, or either list's size differs from the token count
    • annotatorSequence

      public static <F, T extends Comparable<T>> AnnotatorSequence<F,T> annotatorSequence(int sequenceNumber, int totalSequences, Sequence<TaggedPositionedToken<F,T>> taggedSequence, @Nullable List<Set<F>> features, @Nullable List<Set<F>> verboseFeatures, @Nullable ToDoubleFunction<List<T>> probabilityFunction)
      Creates an AnnotatorSequence from a tagger's output, with optional display features and an optional probability function.

      Each token's token, top-scoring tag and corresponding score, and full tag-score set are projected onto a corresponding AnnotatorToken. The alternative-tag-score map preserves the score-descending order of tagScores().

      The features and verboseFeatures lists are index-aligned with the sequence's tokens and populate features and verboseFeatures; a null list means the corresponding feature source is not configured, and every token carries an empty set. Per-token sets are defensively copied.

      The probabilityFunction, when non-null, is carried through to AnnotatorSequence.probabilityOf(List) so the user-interface can display a total likelihood that updates as tags are revised.

      Type Parameters:
      F - the feature type
      T - the tag type
      Parameters:
      sequenceNumber - the 1-based position of this sequence within the overall annotation batch
      totalSequences - the total number of sequences in the overall annotation batch
      taggedSequence - the tagger's output for the sequence
      features - the per-token key display features, or null when not configured
      verboseFeatures - the per-token verbose display features, or null when not configured
      probabilityFunction - the function scoring arbitrary taggings of the sequence, or null when no model backs the sequence
      Returns:
      a new annotator sequence
      Throws:
      IllegalArgumentException - if sequenceNumber < 1, totalSequences < sequenceNumber, taggedSequence is empty, or either list's size differs from the token count
    • annotatorSequence

      public static <F, T extends Comparable<T>> AnnotatorSequence<F,T> annotatorSequence(int sequenceNumber, int totalSequences, List<String> tokens, TagProvider<T> tagProvider, @Nullable List<Set<F>> features, @Nullable List<Set<F>> verboseFeatures)
      Creates an AnnotatorSequence for the no-tagger path, where the user will choose tags from scratch, with optional display features.

      The returned sequence has startingTag as every initial tag, null for every initial confidence, and an alternative-tag-score map per token keyed by tagProvider.tags() (in natural order) with every value null.

      The features and verboseFeatures lists are index-aligned with tokens and populate features and verboseFeatures; a null list means the corresponding feature source is not configured, and every token carries an empty set. Per-token sets are defensively copied.

      Type Parameters:
      F - the feature type
      T - the tag type
      Parameters:
      sequenceNumber - the 1-based position of this sequence within the overall annotation batch
      totalSequences - the total number of sequences in the overall annotation batch
      tokens - the tokens of the sequence
      tagProvider - the tag provider, whose tags set defines the tag space offered on the edit screen
      features - the per-token key display features, or null when not configured
      verboseFeatures - the per-token verbose display features, or null when not configured
      Returns:
      a new annotator sequence
      Throws:
      IllegalArgumentException - if sequenceNumber < 1, totalSequences < sequenceNumber, tokens is empty, tagProvider.tags() is empty, or either list's size differs from the token count
    • taggingResult

      public static <T> TaggingResult<T> taggingResult(TaggingAction action, List<T> finalTags)
      Creates a TaggingResult.

      The finalTags list is defensively copied.

      Type Parameters:
      T - the tag type
      Parameters:
      action - the action chosen by the user
      finalTags - the per-token tags chosen by the user (may be empty)
      Returns:
      a new tagging result