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);Calls to names.Next() will generate names like:
Lika
Ranumi
Marile
MalobaIn the example above:
The vowels
aeiwill appear 4x more likely thanouThe consonants
lmnrwill appear 2.5x more likely than the letterskgpbbecause
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);In this example, all clusters will show up 4x more likely than normal symbols. Calls to names.Next() will generate names like:
Thiashaena
Nilia
SheichiLast updated