MediaPipeTasksText Framework Reference

TextSummarizer

class TextSummarizer: NSObject

Performs summarization on text.

This API expects a LiteRT-LM model asset bundle.

  • Creates a new instance of MPPTextSummarizer from an absolute path to a model asset bundle stored locally on the device and the default MPPTextSummarizerOptions.

    Declaration

    Swift

    convenience init(modelPath: String) throws

    Parameters

    modelPath

    An absolute path to a model file stored locally on the device.

    Return Value

    A new instance of MPPTextSummarizer with the given model path. nil if there is an error in initializing the text summarizer.

  • Creates a new instance of MPPTextSummarizer from the given MPPTextSummarizerOptions.

    Declaration

    Swift

    init(options: TextSummarizerOptions) throws

    Parameters

    options

    The options of type MPPTextSummarizerOptions to use for configuring the MPPTextSummarizer.

    Return Value

    A new instance of MPPTextSummarizer with the given options. nil if there is an error in initializing the text summarizer.

  • Shuts down the MPPTextSummarizer when all the work is done.

    Declaration

    Swift

    func close() throws
  • Performs summarization on the input text.

    Declaration

    Swift

    func summarize(text: String) throws -> TextSummarizerResult

    Parameters

    text

    The NSString on which summarization is to be performed.

    Return Value

    A MPPTextSummarizerResult object that contains the complete summary result.

  • Performs summarization on the input text and returns the result incrementally via the callback.

    Declaration

    Swift

    func summarizeStreaming(text: String, completion completionHandler: @escaping (TextSummarizerStreamResult?, (any Error)?) -> Void) throws

    Parameters

    text

    The input text to be summarized.

    completionHandler

    The completion handler invoked with the incremental summarization result or an error.