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
wordWordThe word to mutate
minEditDistanceintThe minimum edit distance to ensure
alphabetIWordAlphabetThe alphabet we're operating with
randomIRandomThe 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
alphabetorwordis 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
wordWordThe word to mutate
minEditDistanceintThe minimum edit distance to ensure
minWordLengthintA minimum word length to maintain. The mutation will never remove more characters than this
alphabetIWordAlphabetThe alphabet we're operating with
randomIRandomThe 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
alphabetorwordis 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
wordWordThe word to mutate
dictionaryIWordDictionaryThe dictionary to use to look for subwords
randomIRandomThe 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
dictionaryorwordis 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
wordWordThe word to mutate
minWordLengthintA minimum word length to maintain. The mutation will never remove more characters than this
dictionaryIWordDictionaryThe dictionary to use to look for subwords
randomIRandomThe 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
dictionaryorwordis null