Package org.coordinatekit.crf.annotator
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 entriesT- the tag type
- Enclosing class:
Annotator<F,T extends Comparable<T>>
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 Summary
Modifier and TypeMethodDescriptionbuild()Builds the annotator.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.Sets the CRF tagger used to suggest tags for each input line.taggingInterface(TaggingInterface<F, T> taggingInterface) Sets the tagging interface used to present each sequence to the user.tagProvider(TagProvider<T> tagProvider) Sets the tag provider, whoseTagProvider.tags()set defines the tag space.terminal(org.jline.terminal.Terminal terminal) Sets the JLine terminal used to emit the one-line resume message at session start.Sets the tokenizer used to split every input line into tokens and excluded runs.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.
-
Method Details
-
build
Builds the annotator.- Returns:
- a new
Annotator - Throws:
IllegalStateException- iftagProvider,taggingInterface, orterminalhave not been set; if neither atokenizernor ataggerhas been set; or if the suppliedTagProvider.tags()set is empty
-
featureExtractor
Sets the feature extractor used to compute the key display features shown by the feature view of the tagging interface. May benull; whennull, 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, ornullto disable the feature display- Returns:
- this builder
-
tagger
Sets the CRF tagger used to suggest tags for each input line. May benull. 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 thetokenizer(Tokenizer)becomes optional. When absent the tokenizer supplies the tokenization instead.- Parameters:
tagger- the tagger, ornullto run without tag suggestions- Returns:
- this builder
-
tagProvider
Sets the tag provider, whoseTagProvider.tags()set defines the tag space.- Parameters:
tagProvider- the tag provider- Returns:
- this builder
-
taggingInterface
Sets the tagging interface used to present each sequence to the user.- Parameters:
taggingInterface- the tagging interface- Returns:
- this builder
-
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
Sets the tokenizer used to split every input line into tokens and excluded runs. Required only when notaggeris 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 benull; whennulland ataggeris configured, the all-features view falls back to the tagger's embeddedfeatureswhich 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, ornullto use the tagger fallback (or no verbose display)- Returns:
- this builder
-