Sentence Similarity
SkillfulAPI.SentenceSimilarity
SkillfulAPI.SentenceSimilarityOverview
Function Example
using SkillfulAI.API;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SentenceSimilarity : MonoBehaviour
{
/// <summary>
/// Unity's Start method, called when the script is initialized. Initiates the sentence similarity check.
/// </summary>
private void Start()
{
CheckSimilarity();
}
/// <summary>
/// Initiates sentence similarity check based on a specified input sentence and context sentences.
/// </summary>
public void CheckSimilarity()
{
// Context sentences used for comparison
string[] context = new string[] {
"Ham and cheese burger",
"Tomato Salad Burger",
"Steak and Cheese Burger"
};
// Input sentence to compare against the context
string inputSentence = "I really want a yummy steak burger please!";
// Perform sentence similarity check
SkillfulAPI.SentenceSimilarity(inputSentence, context,
(scores, maxScoreIndex, contexts) =>
{
// Get the best match based on score
string bestMatch = contexts[maxScoreIndex];
// Debug the best match
Debug.Log(bestMatch);
},
error =>
{
Debug.LogError($"Error: {error}");
});
}
}Detailed Explanation
Usage Example
Conclusion
Last updated