UtilStringGenerateTypos Method

Simulate random typographical errors in the input text, based on the specified error rate.

Rules:

● The error-rate percentage calculation is done for the input text length, instead of throwing the dice for each character.

● Letters can only be replaced with different letters of the same case (upper-case or lower-case).

● Numbers can only be replaced with different numbers.

● Special characters like punctuation and white-spaces will remain untouched.

Definition

Namespace: DevCase.Core.DataProcessing.Common
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
public static string GenerateTypos(
	string input,
	int errorRate,
	bool letters,
	bool numbers
)

Parameters

input  String
The input text.
errorRate  Int32
The error rate percentage. It must be in the range of 0 to 100.

Note: The error-rate percentage calculation is done for the input text length, instead of throwing the dice for each character.

If this value is 0, no changes are made to the input text.

If error rate is too small for the length of the input text, it may not add any typos.

Suggested values can go between 1 to 5 percent. Higher values will produce more typos, so more unrealistic simulations.

letters  Boolean
Optional. If true, allows to simulate random typographical errors in letters. Default value is True.

Note: Letters can only be replaced with different letters of the same case (upper-case or lower-case).

numbers  Boolean
Optional. If true, allows to simulate random typographical errors in numbers. Default value is True.

Note: Numbers can only be replaced with different numbers.

Return Value

String
The resulting text with random typographical errors added.

Example

This is a code example.
C#
No code example is currently available or this language may not be supported.

See Also