Class RandomInsertion<T>
- Namespace
- AiDotNet.Augmentation.Text
- Assembly
- AiDotNet.dll
Randomly inserts synonyms of existing words into the text.
public class RandomInsertion<T> : TextAugmenterBase<T>, IAugmentation<T, string[]>
Type Parameters
TThe numeric type for calculations.
- Inheritance
-
AugmentationBase<T, string[]>RandomInsertion<T>
- Implements
-
IAugmentation<T, string[]>
- Inherited Members
Remarks
For Beginners: Random insertion adds new words to the text based on synonyms of existing words. For example, "I love programming" might become "I love really programming" if "really" is considered related to context.
When to use:
- Text classification tasks
- Training data expansion
- Making models robust to longer text variations
Constructors
RandomInsertion(int, double, string)
Creates a new random insertion augmentation.
public RandomInsertion(int numInsertions = 1, double probability = 0.2, string languageCode = "en")
Parameters
numInsertionsintNumber of words to insert (default: 1).
probabilitydoubleProbability of applying this augmentation (default: 0.2).
languageCodestringLanguage code for language-specific operations.
Properties
CustomInsertionWords
Gets or sets custom words for insertion.
public Dictionary<string, string[]>? CustomInsertionWords { get; set; }
Property Value
- Dictionary<string, string[]>
NumInsertions
Gets the number of insertions to perform.
public int NumInsertions { get; }
Property Value
Remarks
Default: 1
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.