Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Morphology

Morphology adds internal structure to generated words through affixation. Prefixes and suffixes are defined as patterns that probabilistically attach to words of certain classes. This makes words feel derived rather than invented from whole cloth.

Configuration

Add a morphology section to your config JSON:

{
  "morphology": {
    "decay": 0.5,
    "suffixes": [
      {
        "pattern": "V$K",
        "applies_to": ["verb"],
        "probability": 0.3,
        "label": "past tense"
      },
      {
        "pattern": "C",
        "applies_to": ["noun"],
        "probability": 0.35,
        "label": "plural"
      }
    ],
    "prefixes": [
      {
        "pattern": "CV",
        "applies_to": ["verb", "adj"],
        "probability": 0.1,
        "label": "negation"
      }
    ]
  }
}

Fields

FieldTypeRequiredDescription
decaynumberNoProbability multiplier for each subsequent affix of the same type (prefix or suffix). Default 0.5. Must be between 0.0 and 1.0.
suffixesarrayNoList of suffix definitions.
prefixesarrayNoList of prefix definitions.

Affix Fields

FieldTypeRequiredDescription
patternstringYesA phonotactic pattern using the same pattern syntax as word classes. Space-separated syllables are supported for multi-syllable affixes.
applies_toarrayNoWord classes this affix can attach to. If absent, applies to all classes.
probabilitynumberYesProbability of attachment, between 0.0 and 1.0.
labelstringNoDocumentary label (e.g. “plural”, “past tense”). Has no effect on generation.

Behavior

Application Order

Morphology runs after word generation but before stress assignment. This means stress is computed over the full derived form including affixes, matching how natural languages work (e.g., English “PHOto” vs “phoTOgraphy”).

Decay

When multiple affixes of the same type (prefix or suffix) are defined, each subsequent attachment multiplies its probability by the decay factor. For example, with decay: 0.5 and two suffixes both at probability: 0.3:

  • First suffix: effective probability = 0.3
  • If first attached, second suffix: effective probability = 0.3 * 0.5 = 0.15
  • If both attached, a hypothetical third: effective probability = 0.3 * 0.25 = 0.075

This prevents runaway stacking while still allowing occasional multi-affix words.

Lexicon Integration

When a word class uses a pre-generated lexicon, affixes are baked into the lexicon entries at generation time. This means each lexicon word has its affixes fixed, maintaining consistency when the same word is reused.

Class Filtering

If applies_to is specified, the affix only applies to words of those classes. If applies_to is absent, the affix applies to all word classes. When no word classes are in use, all affixes apply to all words.