class
WordMage::Generator
- WordMage::Generator
- Reference
- Object
Overview
Main word generation engine that combines all components.
Generator is the central class that orchestrates word creation using PhonemeSet, WordSpec, SyllableTemplates, and RomanizationMap. It supports multiple generation modes and handles constraint validation.
Example
generator = Generator.new(
phoneme_set: phonemes,
word_spec: word_spec,
romanizer: romanizer,
mode: GenerationMode::Random
)
word = generator.generate
batch = generator.generate_batch(10)
Defined in:
generator.crConstructors
Instance Method Summary
- #complexity_budget : Int32 | Nil
- #complexity_budget=(complexity_budget : Int32 | Nil)
-
#generate(min_syllables : Int32, max_syllables : Int32) : String
Generates a word with syllable count from a range.
-
#generate(syllable_count : Int32, starting_type : Symbol) : String
Generates a word with both syllable count and starting type.
-
#generate(syllable_count : Int32) : String
Generates a word with a specific syllable count.
-
#generate(starting_type : Symbol) : String
Generates a word with a specific starting type.
-
#generate : String
Generates a single word according to the current mode.
-
#generate_batch(count : Int32) : Array(String)
Generates multiple words.
- #hiatus_escalation_factor : Float32
- #hiatus_escalation_factor=(hiatus_escalation_factor : Float32)
- #max_words : Int32
- #max_words=(max_words : Int32)
- #mode : GenerationMode
- #mode=(mode : GenerationMode)
-
#next_sequential : String | Nil
Gets the next word in sequential mode.
- #phoneme_set : PhonemeSet
- #phoneme_set=(phoneme_set : PhonemeSet)
-
#reset_sequential
Resets sequential generation to start from the beginning.
- #romanizer : RomanizationMap
- #romanizer=(romanizer : RomanizationMap)
- #vowel_harmony : VowelHarmony | Nil
- #vowel_harmony=(vowel_harmony : VowelHarmony | Nil)
- #word_spec : WordSpec
- #word_spec=(word_spec : WordSpec)
Constructor Detail
Creates a new Generator.
Parameters
#phoneme_set
: PhonemeSet containing available consonants and vowels#word_spec
: WordSpec defining generation requirements#romanizer
: RomanizationMap for converting phonemes to text#mode
: GenerationMode (Random, Sequential, or WeightedRandom)#max_words
: Maximum words for sequential mode (default: 1000)#complexity_budget
: Optional complexity budget for melodic control#hiatus_escalation_factor
: Multiplier for hiatus cost as more appear (default: 1.5)#vowel_harmony
: Optional vowel harmony rules
Instance Method Detail
Generates a word with syllable count from a range.
Parameters
min_syllables
: Minimum syllable countmax_syllables
: Maximum syllable count
Returns
A romanized word string with syllables in the specified range
Generates a word with both syllable count and starting type.
Parameters
syllable_count
: Exact number of syllablesstarting_type
: Either:vowel
or:consonant
Returns
A romanized word string with specified syllables and starting type
Generates a word with a specific syllable count.
Parameters
syllable_count
: Exact number of syllables to generate
Returns
A romanized word string with the specified syllable count
Generates a word with a specific starting type.
Parameters
starting_type
: Either:vowel
or:consonant
Returns
A romanized word string starting with the specified phoneme type
Generates a single word according to the current mode.
Returns
A romanized word string
Raises
Raises if sequential mode has no more words available
Generates multiple words.
Parameters
count
: Number of words to generate
Returns
Array of romanized word strings
Gets the next word in sequential mode.
Returns
Next word string, or nil
if no more words available
Note
Only works in Sequential mode. Call #reset_sequential
to start over.
Resets sequential generation to start from the beginning.
Note
Only affects Sequential mode. Has no effect in other modes.