Table of Contents

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

T

The numeric type for calculations.

Inheritance
RandomInsertion<T>
Implements
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

numInsertions int

Number of words to insert (default: 1).

probability double

Probability of applying this augmentation (default: 0.2).

languageCode string

Language 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

int

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

data string[]

The input data.

context AugmentationContext<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.