Class SarcasmDetection
- Namespace
- LMKit.TextAnalysis
- Assembly
- LM-Kit.NET.dll
Provides functionality for detecting sarcasm in text. This class is designed for applications where understanding sarcasm context is crucial, such as customer feedback analysis, social media monitoring, or mental health assessment tools.
public sealed class SarcasmDetection
- Inheritance
-
SarcasmDetection
- Inherited Members
Examples
using LMKit.TextAnalysis;
using LMKit.Model;
using System;
// Initialize the language model (LLM)
LLM languageModel = new LLM("path/to/your/model");
// Create an instance of SarcasmDetection using the LLM
SarcasmDetection sarcasmDetector = new SarcasmDetection(languageModel);
// Text to analyze
string text = "Oh great, another meeting. Just what I needed.";
// Check if the text is sarcastic
bool isSarcastic = sarcasmDetector.IsSarcastic(text);
Console.WriteLine($"Is the text sarcastic? {isSarcastic}");
// Output: "Is the text sarcastic? True"
Remarks
The SarcasmDetection class utilizes a language model to analyze textual content and determine whether it contains sarcasm. It supports both synchronous and asynchronous operations and allows for fine-tuning with custom training data.
Constructors
- SarcasmDetection(LLM)
Initializes a new instance of the SarcasmDetection class.
Properties
- Confidence
Gets the confidence score of the last detection process, ranging from 0 to 1. A score closer to 1 indicates higher confidence in the detection result.
- Model
Gets the LLM instance associated with this SarcasmDetection object.
- UseEmbeddingClassifier
Gets or sets a value indicating whether the classifier should utilize embedding strategy instead of completion.
Methods
- CreateTrainingObject(TrainingDataset, int, bool, int?)
Creates a LoraFinetuning object for fine-tuning a sarcasm detection model using a specified dataset.
- CreateTrainingObject(IList<(string, bool)>, int)
Creates a LoraFinetuning object for fine-tuning a sarcasm detection model using the provided training data.
- GetTrainingData(TrainingDataset, int, bool, int?)
Retrieves training data for fine-tuning a sarcasm detection model from a specified dataset.
- IsSarcastic(string, CancellationToken)
Analyzes the provided text to determine if it contains sarcasm.
- IsSarcasticAsync(string, CancellationToken)
Asynchronously analyzes the provided text to determine if it contains sarcasm.