Package opennlp.tools.sentdetect
Class SentenceDetectorME
java.lang.Object
opennlp.tools.sentdetect.SentenceDetectorME
- All Implemented Interfaces:
- Probabilistic,- SentenceDetector
A sentence detector for splitting up raw text into sentences.
 
A maximum entropy model is used to evaluate end-of-sentence characters in a string to determine if they signify the end of a sentence.
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionSentenceDetectorME(String language) Initializes the sentence detector by downloading a default model.SentenceDetectorME(SentenceModel model) Initializes the current instance.SentenceDetectorME(SentenceModel model, Dictionary abbDict) Instantiates aSentenceDetectorMEwith an existingSentenceModel.SentenceDetectorME(SentenceModel model, Factory factory) Deprecated.
- 
Method SummaryModifier and TypeMethodDescriptiondouble[]Deprecated, for removal: This API element is subject to removal in a future version.Useprobs()instead.double[]probs()Retrieves the probabilities of the last decoded sequence.String[]Detects sentences in given inputCharSequence..Span[]Detects the position of the first words of sentences in aCharSequence.static SentenceModeltrain(String languageCode, ObjectStream<SentenceSample> samples, SentenceDetectorFactory sdFactory, TrainingParameters mlParams) Starts a training of aSentenceModelwith the given parameters.
- 
Field Details- 
SPLITConstant indicates a sentence split.- See Also:
 
- 
NO_SPLITConstant indicates no sentence split.- See Also:
 
 
- 
- 
Constructor Details- 
SentenceDetectorMEInitializes the sentence detector by downloading a default model.- Parameters:
- language- The language of the sentence detector.
- Throws:
- IOException- Thrown if the model cannot be downloaded or saved.
 
- 
SentenceDetectorMEInitializes the current instance.- Parameters:
- model- the- SentenceModel
 
- 
SentenceDetectorMEInstantiates aSentenceDetectorMEwith an existingSentenceModel.- Parameters:
- model- The- SentenceModelto be used.
- abbDict- The- Dictionaryto be used. It must fit the language of the- model.
 
- 
SentenceDetectorMEDeprecated.Use aSentenceDetectorFactoryto extend SentenceDetector functionality.
 
- 
- 
Method Details- 
sentDetectDetects sentences in given inputCharSequence..- Specified by:
- sentDetectin interface- SentenceDetector
- Parameters:
- s- The- CharSequence. to be processed.
- Returns:
- A string array containing individual sentences as elements.
 
- 
sentPosDetectDetects the position of the first words of sentences in aCharSequence.- Specified by:
- sentPosDetectin interface- SentenceDetector
- Parameters:
- s- The- CharSequenceto be processed.
- Returns:
- An span arraycontaining the positions of the end index of every sentence.
 
- 
probspublic double[] probs()Retrieves the probabilities of the last decoded sequence. The sequence was determined based on the previous call tosentDetect(CharSequence).- Specified by:
- probsin interface- Probabilistic
- Returns:
- An array with the same number of probabilities as tokens were sent to
         sentDetect(CharSequence)when it was last called. If not applicable, an empty array is returned.
 
- 
getSentenceProbabilitiesDeprecated, for removal: This API element is subject to removal in a future version.Useprobs()instead.- Returns:
- The probability for each sentence returned for the most recent
     call to sentDetect(CharSequence). If not applicable, an empty array is returned.
 
- 
trainpublic static SentenceModel train(String languageCode, ObjectStream<SentenceSample> samples, SentenceDetectorFactory sdFactory, TrainingParameters mlParams) throws IOException Starts a training of aSentenceModelwith the given parameters.- Parameters:
- languageCode- The ISO language code to train the model. Must not be- null.
- samples- The- ObjectStreamof- SentenceSampleused as input for training.
- sdFactory- The- SentenceDetectorFactoryfor creating related objects as defined via- mlParams.
- mlParams- The- TrainingParametersfor the context of the training process.
- Returns:
- A valid, trained SentenceModelinstance.
- Throws:
- IOException- Thrown if IO errors occurred.
 
 
- 
SentenceDetectorFactoryto extend SentenceDetector functionality.