🔡
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
  • Filtering symbol combos
  • Filtering through regex
  • Filtering multiple things at once
  1. Fine-Tuning Generators

Filtering

Filtering symbol combos

Generators let you block symbol combinations or patterns from showing up in names.

Consider the following generator that does not create names with two consecutive t symbols:

var names = new NameGenerator()
    .Any(x => x
        .First("st")
        .Middle("aeiou")
        .Last("st"))
    .Filter("tt");  // Prevent two t's in a row
See non-fluent version
var consonants = new SymbolGenerator("st");
var vowels = new SymbolGenerator("aeiou");

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

var nameFilter = new NameFilter()
    .Add(new FilterConstraint(FilterCondition.MatchesPattern, "tt"));

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

✅This generator creates names like:

Tostis
Sastus
Tessesos

❌This generator will never create names like:

Sottus
Tottis

Filtering through regex

The following generator uses the symbols m u, but uses a filter to prevent m from appearing at the beginning of a name and prevents u from ending it:

var names = new NameGenerator()
    .Any(x => x
        .First("strlmn")
        .Middle("aeiou"))
    .Filter("^M|u$");
See non-fluent version
var consonants = new SymbolGenerator("st");
var vowels = new SymbolGenerator("aeiou");

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

var nameFilter = new NameFilter()
    .Add(new FilterConstraint(FilterCondition.MatchesPattern, "^M|u$"));

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

This generates names like:

Temaro
Rima
Narumi

Filtering multiple things at once

Calls to the fluent method Filter() implicitly sets a NameFilter on the NameGenerator you are setting up. There can only be one NameFilter on a NameGenerator.

❌Don't do this if you want to filter multiple patterns:

var names = new NameGenerator()
    .Any(x => x
        .First("strlmn")
        .Middle("aeiou"))
    .Filter("^M")
    .Filter("u$")
    .Filter("le"); // Only the last filter gets applied

✅Do this if you want to filter multiple patterns or combos at once:

var names = new NameGenerator()
    .Any(x => x
        .First("strlmn")
        .Middle("aeiou"))
    .Filter(x => x
        .DoNotAllowStart("m")  // All of these get applied
        .DoNotAllowRegex("u$")
        .DoNotAllowSubstring("le"));

This generates names like:

Lisone
Nara
Ronimo

PreviousTransformsNextMore Techniques

Last updated 2 months ago

If you are comfortable using , you can choose to use in your filter.

regular expressions