🔡
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
  • Adjusting weights of symbols
  • Adjusting weights of clusters
  1. Fine-Tuning Generators

Weights

Adjusting weights of symbols

Sometimes certain symbols need to appear more often than others. You can control the frequency of a symbol by setting its weight.

The higher the weight, the more often the symbol will show up in generated names. Consider the following example:

var names = new NameGenerator()
    .Any(x => x
        .First(x => x
            .Add("lmnr").Weight(5)  // Appears more frequently
            .Add("kgpb").Weight(2)) // Appears less frequently
        .Middle(x => x
            .Add("aei").Weight(4)
            .Add("ou").Weight(1)))
    .SetSize(2, 3);
See non-fluent version
var firstSymbols = new SymbolGenerator()
    .Add("lmnr").Weight(5)
    .Add("kgpb").Weight(2);

var middleSymbols = new SymbolGenerator()
    .Add("aei").Weight(4)
    .Add("ou").Weight(1);

var syllableGenerator = new SyllableGenerator()
    .Add(SymbolPosition.First, firstSymbols)
    .Add(SymbolPosition.Middle, middleSymbols);

var names = new NameGenerator();
names.SetSyllables(SyllablePosition.Any, syllableGenerator);
names.SetSize(2, 3);

Calls to names.Next() will generate names like:

Lika
Ranumi
Marile
Maloba

In the example above:

  • The vowels a e i will appear 4x more likely than o u

  • The consonants l m n r will appear 2.5x more likely than the letters k g p b because 5 weight2 weight=2.5\frac{5\space weight}{2\space weight} = 2.52 weight5 weight​=2.5

The default weight of a symbol is 1.

Adjusting weights of clusters

You can set the weight of clusters the same way as you would for regular symbols. Consider the following generator:

var names = new NameGenerator()
    .Any(x => x
        .First(x => x
            .Add("mnlr").Weight(1)
            .Cluster("th", "sh", "ch").Weight(4))
        .Middle(x => x
            .Add("aeiou").Weight(1)
            .Cluster("ia", "ae", "ei").Weight(4)))
    .SetSize(2, 3);
See non-fluent version
var firstSymbols = new SymbolGenerator()
    .Add("mnlr").Weight(1)
    .Cluster("th", "sh", "ch").Weight(4);

var middleSymbols = new SymbolGenerator()
    .Add("aeiou").Weight(1)
    .Cluster("ia", "ae", "ei").Weight(4);

var syllableGenerator = new SyllableGenerator()
    .Add(SymbolPosition.First, firstSymbols)
    .Add(SymbolPosition.Middle, middleSymbols);

var names = new NameGenerator()
    .SetSyllables(SyllablePosition.Any, syllableGenerator)
    .SetSize(2, 3);

In this example, all clusters will show up 4x more likely than normal symbols. Calls to names.Next() will generate names like:

Thiashaena
Nilia
Sheichi
PreviousClustersNextChancing

Last updated 2 months ago