Class RandomDeletion<T>
- Namespace
- AiDotNet.Augmentation.Text
- Assembly
- AiDotNet.dll
Randomly deletes words from text.
public class RandomDeletion<T> : TextAugmenterBase<T>, IAugmentation<T, string[]>
Type Parameters
TThe numeric type for calculations.
- Inheritance
-
AugmentationBase<T, string[]>RandomDeletion<T>
- Implements
-
IAugmentation<T, string[]>
- Inherited Members
Remarks
For Beginners: Random deletion removes some words from text, simulating how people often skip words when speaking quickly or how text might have missing words in noisy transcriptions.
When to use:
- Text classification where exact wording isn't critical
- Training robust models for noisy/incomplete text
- Simulating transcription errors
Constructors
RandomDeletion(double, int, double, string)
Creates a new random deletion augmentation.
public RandomDeletion(double deletionProbability = 0.1, int minWordsToKeep = 1, double probability = 0.2, string languageCode = "en")
Parameters
deletionProbabilitydoubleProbability of deleting each word (default: 0.1).
minWordsToKeepintMinimum words to keep (default: 1).
probabilitydoubleProbability of applying this augmentation (default: 0.2).
languageCodestringLanguage code for language-specific operations.
Properties
DeletionProbability
Gets the probability of deleting each word.
public double DeletionProbability { get; }
Property Value
Remarks
Default: 0.1 (10% of words deleted)
MinWordsToKeep
Gets the minimum number of words to keep.
public int MinWordsToKeep { get; }
Property Value
Remarks
Default: 1
Ensures the text isn't completely deleted.
Methods
ApplyAugmentation(string[], AugmentationContext<T>)
Implement this method to perform the actual augmentation.
protected override string[] ApplyAugmentation(string[] data, AugmentationContext<T> context)
Parameters
datastring[]The input data.
contextAugmentationContext<T>The augmentation context.
Returns
- string[]
The augmented data.
GetParameters()
Gets the parameters of this augmentation.
public override IDictionary<string, object> GetParameters()
Returns
- IDictionary<string, object>
A dictionary of parameter names to values.