Method MutateWord
MutateWord(Word, int, IWordAlphabet, IRandom)
Mutates a word to ensure a specific edit distance. Can add, remove, and mutate letters
public static Word MutateWord(Word word, int minEditDistance, IWordAlphabet alphabet, IRandom random)
Parameters
word
WordThe word to mutate
minEditDistance
intThe minimum edit distance to ensure
alphabet
IWordAlphabetThe alphabet we're operating with
random
IRandomThe random generator to use.
Returns
- Word
The mutated word
Remarks
While it is valid to specify an edit distance higher than
the length of the word, this is not recommended. It is entirely
possible for the algorithm to take a long time to complete, or to
never terminate at all, if this value is too high. A sane range
would keep the value between 2 and word
.Length
Exceptions
- ArgumentNullException
alphabet
orword
is null
MutateWord(Word, int, int, IWordAlphabet, IRandom)
Mutates a word to ensure a specific edit distance. Can add, remove, and mutate letters
public static Word MutateWord(Word word, int minEditDistance, int minWordLength, IWordAlphabet alphabet, IRandom random)
Parameters
word
WordThe word to mutate
minEditDistance
intThe minimum edit distance to ensure
minWordLength
intA minimum word length to maintain. The mutation will never remove more characters than this
alphabet
IWordAlphabetThe alphabet we're operating with
random
IRandomThe random generator to use.
Returns
- Word
The mutated word
Remarks
While it is valid to specify an edit distance higher than
the length of the word, this is not recommended. It is entirely
possible for the algorithm to take a long time to complete, or to
never terminate at all, if this value is too high. A sane range
would keep the value between 2 and word
.Length
Exceptions
- ArgumentNullException
alphabet
orword
is null
MutateWord(Word, IWordDictionary, IRandom)
Mutates a word to ensure a that no substrings are valid words
public static Word MutateWord(Word word, IWordDictionary dictionary, IRandom random)
Parameters
word
WordThe word to mutate
dictionary
IWordDictionaryThe dictionary to use to look for subwords
random
IRandomThe random generator to use.
Returns
- Word
The mutated word
Remarks
In the event that the source word already contains no substrings, no mutation operations will be performed and the source word will be returned as-is
Exceptions
- ArgumentNullException
dictionary
orword
is null
MutateWord(Word, int, IWordDictionary, IRandom)
Mutates a word to ensure a that no substrings are valid words
public static Word MutateWord(Word word, int minWordLength, IWordDictionary dictionary, IRandom random)
Parameters
word
WordThe word to mutate
minWordLength
intA minimum word length to maintain. The mutation will never remove more characters than this
dictionary
IWordDictionaryThe dictionary to use to look for subwords
random
IRandomThe random generator to use.
Returns
- Word
The mutated word
Remarks
In the event that the source word already contains no substrings, no mutation operations will be performed and the source word will be returned as-is
Exceptions
- ArgumentNullException
dictionary
orword
is null