Class AnnotatorModels
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 Summary
Modifier and TypeMethodDescriptionstatic <F,T extends Comparable<T>>
AnnotatorSequence<F, T> annotatorSequence(int sequenceNumber, int totalSequences, List<String> tokens, TagProvider<T> tagProvider) Creates anAnnotatorSequencefor the no-tagger path, with no display features.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 anAnnotatorSequencefor the no-tagger path, where the user will choose tags from scratch, with optional display features.static <F,T extends Comparable<T>>
AnnotatorSequence<F, T> annotatorSequence(int sequenceNumber, int totalSequences, Sequence<TaggedPositionedToken<F, T>> taggedSequence) Creates anAnnotatorSequencefrom a tagger's output, with no display features.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 anAnnotatorSequencefrom a tagger's output, with optional display features and no probability function.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 anAnnotatorSequencefrom a tagger's output, with optional display features and an optional probability function.static <T> TaggingResult<T> taggingResult(TaggingAction action, List<T> finalTags) Creates aTaggingResult.
-
Method Details
-
annotatorSequence
public static <F,T extends Comparable<T>> AnnotatorSequence<F,T> annotatorSequence(int sequenceNumber, int totalSequences, Sequence<TaggedPositionedToken<F, T>> taggedSequence) Creates anAnnotatorSequencefrom a tagger's output, with no display features.Equivalent to
annotatorSequence(sequenceNumber, totalSequences, taggedSequence, null, null).- Type Parameters:
F- the feature typeT- the tag type- Parameters:
sequenceNumber- the 1-based position of this sequence within the overall annotation batchtotalSequences- the total number of sequences in the overall annotation batchtaggedSequence- the tagger's output for the sequence- Returns:
- a new annotator sequence
- Throws:
IllegalArgumentException- ifsequenceNumber < 1ortotalSequences < sequenceNumber
-
annotatorSequence
public static <F,T extends Comparable<T>> AnnotatorSequence<F,T> annotatorSequence(int sequenceNumber, int totalSequences, List<String> tokens, TagProvider<T> tagProvider) Creates anAnnotatorSequencefor the no-tagger path, with no display features.Equivalent to
annotatorSequence(sequenceNumber, totalSequences, tokens, tagProvider, null, null).- Type Parameters:
F- the feature typeT- the tag type- Parameters:
sequenceNumber- the 1-based position of this sequence within the overall annotation batchtotalSequences- the total number of sequences in the overall annotation batchtokens- the tokens of the sequencetagProvider- the tag provider, whosetagsset defines the tag space offered on the edit screen- Returns:
- a new annotator sequence
- Throws:
IllegalArgumentException- ifsequenceNumber < 1,totalSequences < sequenceNumber,tokensis empty, ortagProvider.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 anAnnotatorSequencefrom 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 typeT- the tag type- Parameters:
sequenceNumber- the 1-based position of this sequence within the overall annotation batchtotalSequences- the total number of sequences in the overall annotation batchtaggedSequence- the tagger's output for the sequencefeatures- the per-token key display features, ornullwhen not configuredverboseFeatures- the per-token verbose display features, ornullwhen not configured- Returns:
- a new annotator sequence
- Throws:
IllegalArgumentException- ifsequenceNumber < 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 anAnnotatorSequencefrom a tagger's output, with optional display features and an optional probability function.Each token's
token, top-scoringtagand corresponding score, and fulltag-scoreset are projected onto a correspondingAnnotatorToken. The alternative-tag-score map preserves the score-descending order oftagScores().The
featuresandverboseFeatureslists are index-aligned with the sequence's tokens and populatefeaturesandverboseFeatures; anulllist 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 toAnnotatorSequence.probabilityOf(List)so the user-interface can display a total likelihood that updates as tags are revised.- Type Parameters:
F- the feature typeT- the tag type- Parameters:
sequenceNumber- the 1-based position of this sequence within the overall annotation batchtotalSequences- the total number of sequences in the overall annotation batchtaggedSequence- the tagger's output for the sequencefeatures- the per-token key display features, ornullwhen not configuredverboseFeatures- the per-token verbose display features, ornullwhen not configuredprobabilityFunction- the function scoring arbitrary taggings of the sequence, ornullwhen no model backs the sequence- Returns:
- a new annotator sequence
- Throws:
IllegalArgumentException- ifsequenceNumber < 1,totalSequences < sequenceNumber,taggedSequenceis 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 anAnnotatorSequencefor the no-tagger path, where the user will choose tags from scratch, with optional display features.The returned sequence has
startingTagas every initial tag,nullfor every initial confidence, and an alternative-tag-score map per token keyed bytagProvider.tags()(in natural order) with every valuenull.The
featuresandverboseFeatureslists are index-aligned withtokensand populatefeaturesandverboseFeatures; anulllist 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 typeT- the tag type- Parameters:
sequenceNumber- the 1-based position of this sequence within the overall annotation batchtotalSequences- the total number of sequences in the overall annotation batchtokens- the tokens of the sequencetagProvider- the tag provider, whosetagsset defines the tag space offered on the edit screenfeatures- the per-token key display features, ornullwhen not configuredverboseFeatures- the per-token verbose display features, ornullwhen not configured- Returns:
- a new annotator sequence
- Throws:
IllegalArgumentException- ifsequenceNumber < 1,totalSequences < sequenceNumber,tokensis empty,tagProvider.tags()is empty, or either list's size differs from the token count
-
taggingResult
Creates aTaggingResult.The
finalTagslist is defensively copied.- Type Parameters:
T- the tag type- Parameters:
action- the action chosen by the userfinalTags- the per-token tags chosen by the user (may be empty)- Returns:
- a new tagging result
-