Package com.gengoai.hermes.annotator
Class ViterbiAnnotator
- java.lang.Object
-
- com.gengoai.hermes.annotator.Annotator
-
- com.gengoai.hermes.annotator.SentenceLevelAnnotator
-
- com.gengoai.hermes.annotator.ViterbiAnnotator
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
FuzzyLexiconAnnotator
public abstract class ViterbiAnnotator extends SentenceLevelAnnotator
An abstract base annotator that uses the Viterbi algorithm to find text items in a document. Child classes implement the
scoreSpan
andcreateAndAttachAnnotation
methods to score individual spans and attach to the document. Child implementations may also overridecombineScore
to change how scores are combined, by default they are multiplied.- Author:
- David B. Bracewell
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ViterbiAnnotator(int maxSpanSize)
Default constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
annotate(Annotation sentence)
Annotates a single sentence.protected double
combineScore(double currentScore, double spanScore)
Combines the score of a possible span with that of the spans up to this point to determine the optimal segmentation.protected abstract void
createAndAttachAnnotation(Document document, LexiconMatch span)
Given an possible span determines if an annotation should be created and if so creates and attaches it.protected abstract LexiconEntry
scoreSpan(HString span)
Scores the given span.-
Methods inherited from class com.gengoai.hermes.annotator.SentenceLevelAnnotator
annotateImpl, furtherRequires, requires
-
Methods inherited from class com.gengoai.hermes.annotator.Annotator
annotate, getProvider, satisfies
-
-
-
-
Method Detail
-
annotate
protected final void annotate(Annotation sentence)
Description copied from class:SentenceLevelAnnotator
Annotates a single sentence.- Specified by:
annotate
in classSentenceLevelAnnotator
- Parameters:
sentence
- The sentence to annotate
-
combineScore
protected double combineScore(double currentScore, double spanScore)
Combines the score of a possible span with that of the spans up to this point to determine the optimal segmentation.- Parameters:
currentScore
- The score of the sentence so farspanScore
- The score of the span under consideration- Returns:
- The combination of the current and span scores
-
createAndAttachAnnotation
protected abstract void createAndAttachAnnotation(Document document, LexiconMatch span)
Given an possible span determines if an annotation should be created and if so creates and attaches it.- Parameters:
document
- the documentspan
- The span to check
-
scoreSpan
protected abstract LexiconEntry scoreSpan(HString span)
Scores the given span.- Parameters:
span
- The span- Returns:
- The score of the span
-
-