Class NameFinderME
java.lang.Object
opennlp.tools.namefind.NameFinderME
- All Implemented Interfaces:
opennlp.tools.ml.Probabilistic, opennlp.tools.namefind.TokenNameFinder
public class NameFinderME
extends Object
implements opennlp.tools.namefind.TokenNameFinder, opennlp.tools.ml.Probabilistic
A maximum-entropy-based
name finder implementation.- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionNameFinderME(TokenNameFinderModel model) Initializes aNameFinderMEwith aTokenNameFinderModel. -
Method Summary
Modifier and TypeMethodDescriptionvoidstatic opennlp.tools.util.Span[]dropOverlappingSpans(opennlp.tools.util.Span[] spans) Removesspanswith are intersecting or crossing in any way.opennlp.tools.util.Span[]opennlp.tools.util.Span[]Generates name tags for the given sequence, typically a sentence, returningtoken spansfor any identified names.double[]probs()The sequence was determined based on the previous call tofind(String[]).voidprobs(double[] probs) Populates the specified array with the probabilities of the last decoded sequence.double[]probs(opennlp.tools.util.Span[] spans) Retrieves an array of probabilities for each of the specified spans which is the arithmetic mean of the probabilities for each of the outcomes which make up the span.static TokenNameFinderModeltrain(String languageCode, String type, opennlp.tools.util.ObjectStream<opennlp.tools.namefind.NameSample> samples, opennlp.tools.util.TrainingParameters params, TokenNameFinderFactory factory) Starts a training of aTokenNameFinderModelwith the given parameters.
-
Field Details
-
DEFAULT_BEAM_SIZE
public static final int DEFAULT_BEAM_SIZE- See Also:
-
START
- See Also:
-
CONTINUE
- See Also:
-
OTHER
- See Also:
-
-
Constructor Details
-
NameFinderME
Initializes aNameFinderMEwith aTokenNameFinderModel.- Parameters:
model- TheTokenNameFinderModelto initialize with.
-
-
Method Details
-
find
- Specified by:
findin interfaceopennlp.tools.namefind.TokenNameFinder
-
find
Generates name tags for the given sequence, typically a sentence, returningtoken spansfor any identified names.- Parameters:
tokens- An array of the tokens or words of a sequence, typically a sentence.additionalContext- Features which are based on context outside of the sentence but which should also be used.- Returns:
- An array of
token spansfor each of the names identified.
-
clearAdaptiveData
public void clearAdaptiveData()- Specified by:
clearAdaptiveDatain interfaceopennlp.tools.namefind.TokenNameFinder
-
probs
public void probs(double[] probs) Populates the specified array with the probabilities of the last decoded sequence. The sequence was determined based on the previous call tofind(String[]). The specified array should be at least as large as the number of tokens in the previous call tofind(String[]).- Parameters:
probs- An array with the probabilities of the last decoded sequence.
-
probs
public double[] probs()The sequence was determined based on the previous call tofind(String[]).- Specified by:
probsin interfaceopennlp.tools.ml.Probabilistic- Returns:
- An array with the same number of probabilities as tokens were sent
to
find(String[])when it was last called.
-
probs
public double[] probs(opennlp.tools.util.Span[] spans) Retrieves an array of probabilities for each of the specified spans which is the arithmetic mean of the probabilities for each of the outcomes which make up the span.- Parameters:
spans- Thespansof the names for which probabilities are requested.- Returns:
- An array of probabilities for each of the specified spans.
-
train
public static TokenNameFinderModel train(String languageCode, String type, opennlp.tools.util.ObjectStream<opennlp.tools.namefind.NameSample> samples, opennlp.tools.util.TrainingParameters params, TokenNameFinderFactory factory) throws IOException Starts a training of aTokenNameFinderModelwith the given parameters.- Parameters:
languageCode- The ISO conform language code.type- The type to use.samples- TheObjectStreamofNameSampleused as input for training.params- TheTrainingParametersfor the context of the training.factory- TheTokenNameFinderFactoryfor creating related objects defined viaparams.- Returns:
- A valid, trained
TokenNameFinderModelinstance. - Throws:
IOException- Thrown if IO errors occurred during training.
-
dropOverlappingSpans
public static opennlp.tools.util.Span[] dropOverlappingSpans(opennlp.tools.util.Span[] spans) Removesspanswith are intersecting or crossing in any way.The following rules are used to remove the spans:
Identical spans: The first span in the array after sorting it remains.
Intersecting spans: The first span after sorting remains.
Contained spans: All spans which are contained by another are removed.- Parameters:
spans- The inputspans.- Returns:
- The resulting non-overlapping
spans.
-