TextSummarizer
class TextSummarizer: NSObjectPerforms summarization on text.
This API expects a LiteRT-LM model asset bundle.
-
Creates a new instance of
MPPTextSummarizerfrom an absolute path to a model asset bundle stored locally on the device and the defaultMPPTextSummarizerOptions.Declaration
Swift
convenience init(modelPath: String) throwsParameters
modelPathAn absolute path to a model file stored locally on the device.
Return Value
A new instance of
MPPTextSummarizerwith the given model path.nilif there is an error in initializing the text summarizer. -
Creates a new instance of
MPPTextSummarizerfrom the givenMPPTextSummarizerOptions.Declaration
Swift
init(options: TextSummarizerOptions) throwsParameters
optionsThe options of type
MPPTextSummarizerOptionsto use for configuring theMPPTextSummarizer.Return Value
A new instance of
MPPTextSummarizerwith the given options.nilif there is an error in initializing the text summarizer. -
Shuts down the
MPPTextSummarizerwhen all the work is done.Declaration
Swift
func close() throws -
Performs summarization on the input text.
Declaration
Swift
func summarize(text: String) throws -> TextSummarizerResultParameters
textThe
NSStringon which summarization is to be performed.Return Value
A
MPPTextSummarizerResultobject that contains the complete summary result. -
Performs summarization on the input
textand returns the result incrementally via the callback.Declaration
Swift
func summarizeStreaming(text: String, completion completionHandler: @escaping (TextSummarizerStreamResult?, (any Error)?) -> Void) throwsParameters
textThe input text to be summarized.
completionHandlerThe completion handler invoked with the incremental summarization result or an error.