Text Summary

SkillfulAPI.TextSummarization

Overview

The TextSummarization class provides functionality to summarize a given input text. This can be useful for condensing information, creating concise content summaries, or extracting key points from longer texts.

Class Definition

using SkillfulAI.API;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TextSummarization : MonoBehaviour
{
    /// <summary>
    /// Unity's Start method, called when the script is initialized. Initiates the text summarization process.
    /// </summary>
    void Start()
    {
        SummarizeText();
    }

    /// <summary>
    /// Initiates text summarization based on a specified input text.
    /// </summary>
    public void SummarizeText()
    {
        // Input text to be summarized
        string inputText = "The cab arrived late. The inside was in as bad of shape as the outside which was concerning, and it didn't appear that it had been cleaned in months. The green tree air-freshener hanging from the rearview mirror was either exhausted of its scent or not strong enough to overcome the other odors emitting from the cab. The correct decision, in this case, was to get the hell out of it and to call another cab, but she was late and didn't have a choice.";

        // Perform text summarization on the input text
        SkillfulAPI.Summarization(inputText, result =>
        {
            Debug.Log(result);
        });
    }
}

Detailed Explanation

Start Method

Description: Unity's Start method is called when the script is first initialized. This method triggers the text summarization process.

Code:

void Start()
{
    SummarizeText();
}

Functionality:

  • Automatically invokes the SummarizeText method when the script starts.

  • Useful for initializing processes or setting up functionalities as soon as the script is activated.

SummarizeText Method

Description: The SummarizeText method sends a specified input text to the SkillfulAI API for summarization and logs the result.

Code:

public void SummarizeText()
{
    // Input text to be summarized
    string inputText = "The cab arrived late. The inside was in as bad of shape as the outside which was concerning, and it didn't appear that it had been cleaned in months. The green tree air-freshener hanging from the rearview mirror was either exhausted of its scent or not strong enough to overcome the other odors emitting from the cab. The correct decision, in this case, was to get the hell out of it and to call another cab, but she was late and didn't have a choice.";

    // Perform text summarization on the input text
    SkillfulAPI.Summarization(inputText, result =>
    {
        Debug.Log(result);
    });
}

Functionality:

  • Sends the input text to the SkillfulAI API for summarization.

  • Logs the summarized result received from the API response.

  • Provides a concise summary of the provided text, which can be useful for quick content reviews or previews.

Usage Example

  1. Add the Script to a GameObject:

    • Attach the TextSummarization script to any GameObject in your Unity scene.

  2. Run the Scene:

    • Upon starting the scene, the SummarizeText method will be invoked automatically.

    • The specified input text will be sent to the SkillfulAI API, and the summarized text will be logged to the console.

Conclusion

The TextSummarization function illustrates a basic implementation of text summarization using the SkillfulAI Gaming SDK. By summarizing longer texts, you can provide more digestible content and enhance user experience in your Unity project.

Last updated