Phonotactics.h header
#include <ew/core/Phonotactics.h>
Namespace ew::core
Phonotactics struct
struct ew::core::Phonotactics
The phonotactics of a constructed language: the structured rules that decide which sequences of sounds form a legal word, layered over the flat PhonemeInventory. It supersedes the old space-separated syllable-pattern string, which still parses into it on load (see phonotacticsFromLegacy). Together the inventory and phonotactics fully specify the word generator: named sound categories, weighted syllable templates, a length-distribution dropoff plus a monosyllableWeight bias, sequence forbiddenSequences that a word may never contain, optional vowel-harmonyGroups, and ordered post-generation rewriteRules.
Members
std::vector<SoundCategory> ew::core::Phonotactics::categories
The named sound categories templates draw on (e.g. C, V, R).
std::vector<SyllableTemplate> ew::core::Phonotactics::templates
The weighted syllable shapes a word is assembled from. Empty means "one CV syllable".
std::vector<RewriteRule> ew::core::Phonotactics::rewriteRules
Ordered post-generation rewrite rules (allophony/orthography); applied after assembly.
std::vector<QString> ew::core::Phonotactics::forbiddenSequences
Substrings a generated word may never contain; a candidate that matches any is rejected and re-rolled. Case-sensitive, matched against the assembled (pre-rewrite) word.
std::vector<std::vector<QString> > ew::core::Phonotactics::harmonyGroups
Optional vowel-harmony groups: each inner list is a set of vowel graphemes that agree within a word. When non-empty, the first vowel a word generates fixes the group and every later vowel is restricted to that same group. Empty means no harmony constraint.
SyllableDropoff ew::core::Phonotactics::dropoff =
How sharply the generator favours shorter words when choosing a syllable count.
int ew::core::Phonotactics::monosyllableWeight = 0
Extra bias toward one-syllable words: added to the selection weight of a single-syllable word on top of the dropoff distribution. Zero means the dropoff alone decides. Negative values are treated as zero by the generator.
bool ew::core::Phonotactics::isEmpty() const
Whether the phonotactics carry no rules at all (so a language falls back to defaults).
const std::vector< QString > & ew::core::Phonotactics::categoryMembers(const QString &symbol) const
The members of the category named symbol, or an empty list if no such category exists.
bool ew::core::Phonotactics::operator==(const Phonotactics &other) const =default
Value equality over all fields.
RewriteRule struct
struct ew::core::RewriteRule
A post-generation rewrite applied to a finished word: every occurrence of match is replaced by replacement. Rules model allophony and orthographic conventions the raw syllable assembly does not (e.g. "ki" -> "tʃi"). Rules apply in list order, each to the output of the previous one, in a single left-to-right pass so a rule cannot feed on its own output and loop.
Members
QString ew::core::RewriteRule::match
The substring to look for (non-empty for the rule to have any effect).
QString ew::core::RewriteRule::replacement
The text to replace each occurrence of match with (may be empty to delete it).
bool ew::core::RewriteRule::operator==(const RewriteRule &other) const =default
Value equality over all fields.
SoundCategory struct
struct ew::core::SoundCategory
A named class of sounds a syllable template can draw on – the phonotactics counterpart to the "C=..." category definitions in the Zompist word generator. The symbol is the single letter used in a template (e.g. C, V, R for liquids), and members are the phoneme graphemes that fill that slot. A phoneme's generation frequency comes from its weight in the inventory, so a category only lists which sounds are eligible, not how often each occurs.
Members
QString ew::core::SoundCategory::symbol
The symbol used to reference this category in a syllable template (e.g. "C"). Conventionally a single upper-case letter, but any non-empty token works.
std::vector<QString> ew::core::SoundCategory::members
The phoneme graphemes eligible in this slot (e.g. {"p", "t", "k"}); drawn from the inventory.
bool ew::core::SoundCategory::operator==(const SoundCategory &other) const =default
Value equality over all fields.
SyllableTemplate struct
struct ew::core::SyllableTemplate
One weighted syllable shape a word may be built from: a sequence of category symbols (and optional literal characters), plus a relative frequency weight. A word is assembled by drawing templates by weight and filling each category slot; a template like "CVC" with weight 3 is chosen three times as often as an otherwise-equal template of weight 1.
Members
QString ew::core::SyllableTemplate::shape
The syllable shape as category symbols with optional literals (e.g. "CVC", "CV", "V"). A character that is not a defined category symbol is emitted literally (e.g. an apostrophe).
int ew::core::SyllableTemplate::weight = 1
Relative frequency weight (at least 1): higher means this shape is chosen more often.
bool ew::core::SyllableTemplate::operator==(const SyllableTemplate &other) const =default
Value equality over all fields.
Enumerations
enum class SyllableDropoff { Equiprobable, Slow, Medium, Fast }
How sharply a constructed language favours shorter words: the shape of the distribution the word generator draws a syllable count from, between the language's minimum and maximum. Equiprobable gives every length the same chance; the others bias progressively harder toward the minimum, the way natural lexicons cluster around one or two syllables. Serialized as a stable lowercase token.
Functions
Phonotactics ew::core::phonotacticsFromLegacy(const QString &patterns, const PhonemeInventory &inventory)
Builds a Phonotactics from the legacy space-separated syllable-patterns string (the pre-phonotactics model) and the language's inventory: each whitespace-separated pattern token becomes a unit-weight SyllableTemplate (falling back to a single "CV" template when empty), and two categories are synthesized from the inventory – "C" gathering every non-vowel phoneme grapheme and "V" every vowel – so the old C/V patterns keep working. Used to migrate an old language on load so no generation behaviour is lost; the remaining rules start empty.
std::optional< SyllableDropoff > ew::core::syllableDropoffFromToken(QStringView token)
Parses a syllable-dropoff mode from its serialization token; std::nullopt if unrecognized.
QString ew::core::toToken(SyllableDropoff dropoff)
The stable serialization token for dropoff (e.g. "fast").