🔡
Syllabore
GitHub
  • Overview
  • Starting Out
  • Fine-Tuning Generators
    • Positioning
    • Clusters
    • Weights
    • Chancing
    • Transforms
    • Filtering
  • More Techniques
    • Formatters
    • Generator Pools
    • Syllable Sets
    • Generator Serialization
  • More Examples
    • Soft/Hard-Sounding Names
    • Fantasy Names
    • Spaceship Names
    • Futuristic City Names
  • Class Docs
    • FilterCondition
    • FilterConstraint
    • GeneratorPool<T>
    • INameFilter
    • INameTransformer
    • IPotentialAction
    • IRandomizable
    • ISyllableGenerator
    • Name
    • NameFilter
    • NameFormat
    • NameFormatter
    • NameFormatterGeneratorOptions
    • NameGenerator
    • NameGeneratorSerializer
    • NameGeneratorTypeInformation
    • SerializedNameGenerator
    • SyllableGenerator
    • SyllableGeneratorFluentWrapper
    • SyllablePosition
    • SyllableSet
    • Symbol
    • SymbolGenerator
    • SymbolPosition
    • Transform
    • TransformSet
    • TransformStep
    • TransformStepType
Powered by GitBook
On this page
  • Using a basic transform
  • Using a multistep transform
  • Using a probabilistic transform
  • Chancing a transform
  1. Fine-Tuning Generators

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);
See non-fluent version
var consonants = new SymbolGenerator("lmnstr");
var vowels = new SymbolGenerator("aeiou");

var syllables = new SyllableGenerator()
    .Add(SymbolPosition.First, consonants)
    .Add(SymbolPosition.Middle, vowels);

var step = new TransformStep(TransformStepType.AppendSyllable, "nia");
var transform = new Transform().AddStep(step);

var names = new NameGenerator()
    .SetSyllables(SyllablePosition.Any, syllables)
    .SetTransform(transform)
    .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);
See non-fluent version
var consonants = new SymbolGenerator("lmnstr");
var vowels = new SymbolGenerator("aeiou");

var syllables = new SyllableGenerator()
    .Add(SymbolPosition.First, consonants)
    .Add(SymbolPosition.Middle, vowels);

var step1 = new TransformStep(TransformStepType.InsertSyllable, "0", "za");
var step2 = new TransformStep(TransformStepType.AppendSyllable, "nia");

var transform = new Transform()
    .AddStep(step1)
    .AddStep(step2);

var names = new NameGenerator()
    .SetSyllables(SyllablePosition.Any, syllables)
    .SetTransform(transform)
    .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);
See non-fluent version
var consonants = new SymbolGenerator("lmnstr");
var vowels = new SymbolGenerator("aeiou");

var syllables = new SyllableGenerator()
    .Add(SymbolPosition.First, consonants)
    .Add(SymbolPosition.Middle, vowels);

var transform1 = new Transform()
    .AddStep(new TransformStep(TransformStepType.ReplaceSyllable, "-1", "des"));

var transform2 = new Transform()
    .AddStep(new TransformStep(TransformStepType.ReplaceSyllable, "-1", "rus"));
 
var transform3 = new Transform()
    .AddStep(new TransformStep(TransformStepType.ReplaceSyllable, "-1", "vium"));

var transformSet = new TransformSet()
    .RandomlySelect(1)
    .Add(transform1)
    .Add(transform2)
    .Add(transform3);

var names = new NameGenerator();
names.SetSyllables(SyllablePosition.Any, syllables);
names.SetTransform(transformSet);
names.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);
See non-fluent version
var consonants = new SymbolGenerator("lmnstr");
var vowels = new SymbolGenerator("aeiou");

var syllables = new SyllableGenerator()
    .Add(SymbolPosition.First, consonants)
    .Add(SymbolPosition.Middle, vowels);

var transform1 = new Transform()
    .AddStep(new TransformStep(TransformStepType.ReplaceSyllable, "-1", "des"));

var transform2 = new Transform()
    .AddStep(new TransformStep(TransformStepType.ReplaceSyllable, "-1", "rus"));
 
var transform3 = new Transform()
    .AddStep(new TransformStep(TransformStepType.ReplaceSyllable, "-1", "vium"));

var transformSet = new TransformSet()
    .Chance(0.5)
    .RandomlySelect(1)
    .Add(transform1)
    .Add(transform2)
    .Add(transform3);

var names = new NameGenerator();
names.SetSyllables(SyllablePosition.Any, syllables);
names.SetTransform(transformSet);
names.SetSize(3);

This results in names like:

Rumiri
Tetades
Semate
PreviousChancingNextFiltering

Last updated 2 months ago