Class Annotator<F,T extends Comparable<T>>
- Type Parameters:
F- the feature type carried by the tagger and the per-token entriesT- the tag type
Each non-blank input line is tokenized and presented through the configured
TaggingInterface. When the user accepts a sequence, the resulting tokens, tags, and the
excluded character runs the tokenizer dropped around them are appended to the output XML file as
a <crf:Sequence> element and flushed immediately, so a crash leaves a valid (or
recoverable) document with every confirmed sequence intact. The captured excluded runs make the
written sequence losslessly reconstructable: TrainingSequence.surface() reproduces the
original line exactly. Re-running against the same output file skips any input line whose
tokenization matches one already present in the output, compared by a 64-bit content fingerprint
of the token list (content-match resume).
When a CrfTagger is configured it is the authoritative source of tokens and excluded
runs. Each line is tagged once, the tagger's tokenization is used as written, and its suggested
tags are always shown. When no tagger is configured the Tokenizer splits each line
instead and the user tags every token starting from TagProvider.startingTag(). At least
one of the two must be present.
The "Sequence N of M" counters reported through AnnotatorSequence use a stable
denominator: M is the total number of non-blank input lines, including lines already
present in the output (so "of M" does not drift between sessions). N is the position of
the shown sequence within that input — the number of lines auto-skipped so far plus the number
presented so far — so resuming after 50 skipped lines shows the next sequence as "51 of M".
Instances are constructed via the nested Annotator.Builder.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classAnnotator.Builder<F,T extends Comparable<T>> Builder forAnnotator. -
Method Summary
Modifier and TypeMethodDescriptionvoidAnnotates the input file, appending accepted sequences to the output file.static <F,T extends Comparable<T>>
Annotator.Builder<F, T> builder()Returns a new builder forAnnotator.
-
Method Details
-
builder
Returns a new builder forAnnotator.- Type Parameters:
F- the feature type carried by the tagger and the per-token entriesT- the tag type- Returns:
- a new builder with no values set
-
annotate
Annotates the input file, appending accepted sequences to the output file.Walks
inputFileline-by-line, skipping blank lines and any line whose token list is already present inoutputFile. Each remaining line is tokenized by the configuredTokenizer, built into anAnnotatorSequence, and presented via the configuredTaggingInterface. OnACCEPTthe tokens, the user-chosen tags, and the tokenizer's excluded runs are written and flushed to the output file. OnSKIPthe line is left unwritten and will be re-presented on the next run. OnEXITthe writer is closed and this method returns.A one-line "Resumed: skipped K of N input lines already present in output." message is written to the configured
Terminalonce per call — either immediately before the first presentation, or after the input is exhausted if no presentation occurred.- Parameters:
inputFile- the file to read input lines from, UTF-8 encoded, one sequence per lineoutputFile- the XML training-data file to append accepted sequences to- Throws:
IOException- if reading the input, reading the existing output, or writing the output fails
-