Transforms
In Syllabore, a transform is any action that changes a name.
Using a basic transform
Consider the following generator that makes all names share the same suffix -nia
:
var names = new NameGenerator()
.Any(x => x // For all syllables...
.First("lmnstr") // Use these consonants
.Middle("aeiou")) // And these vowels
.Transform(x => x.Append("nia")) // Then add this suffix to the final name
.SetSize(2);
Calls to names.Next()
will produce names like:
Surunia
Timania
Lisonia
Using a multistep transform
A transform is made up of transform steps. Steps are actions like:
Inserting, replacing, or deleting a syllable
Replacing a syllable or a substring
You are are allowed to have more than one step in a transform:
var names = new NameGenerator()
.Any(x => x
.First("lmnstr")
.Middle("aeiou"))
.Transform(x => x
.Insert(0, "za") // First add "za" to the beginning
.Append("nia")) // Then add "nia" to the end
.SetSize(2);
This generator creates names like:
Zasurania
Zatamunia
Zarutonia
Using a probabilistic transform
You can choose to add randomization to your transforms by using a TransformSet
. Consider this generator:
var names = new NameGenerator()
.Any(x => x
.First("lmnstr")
.Middle("aeiou"))
.Transform(new TransformSet()
.RandomlySelect(1) // Only perform one transform
.Add(x => x.Replace(-1, "des")) // "-1" targets the end syllable
.Add(x => x.Replace(-1, "rus"))
.Add(x => x.Replace(-1, "vium")))
.SetSize(3);
This generator replaces the last syllable with one of the suffixes -des
-rus
or -vium
. The names that come out of this generator look like this:
Sunerus
Lasuvium
Nerades
Chancing a transform
Finally, when using a TransformSet
, you can also specify a probability of any transform being used through the Chance()
method.
var names = new NameGenerator()
.Any(x => x
.First("lmnstr")
.Middle("aeiou"))
.Transform(new TransformSet()
.Chance(0.5) // Only use a transform 50% of the time
.RandomlySelect(1) // Only perform one transform
.Add(x => x.Replace(-1, "des"))
.Add(x => x.Replace(-1, "rus"))
.Add(x => x.Replace(-1, "vium")))
.SetSize(3);
This results in names like:
Rumiri
Tetades
Semate
Last updated