struct
WordMage::SyllableCountSpec
- WordMage::SyllableCountSpec
- Struct
- Value
- Object
Overview
Specifies how many syllables a word should have.
Supports three modes:
- Exact: Always generate exactly N syllables
- Range: Generate between min and max syllables (uniform distribution)
- Weighted: Generate syllables according to weighted probabilities
Example
exact = SyllableCountSpec.exact(3) # Always 3 syllables
range = SyllableCountSpec.range(2, 4) # 2-4 syllables
weighted = SyllableCountSpec.weighted({2 => 1.0, 3 => 3.0, 4 => 1.0}) # Prefer 3
Defined in:
word_spec.crConstructors
Class Method Summary
-
.exact(count : Int32)
Creates a spec for exactly N syllables.
-
.range(min : Int32, max : Int32)
Creates a spec for a range of syllables with uniform distribution.
-
.weighted(weights : Hash(Int32, Float32))
Creates a spec for weighted syllable distribution.
Instance Method Summary
-
#generate_count : Int32
Generates a syllable count according to this spec.
- #max : Int32
- #min : Int32
- #type : Type
- #weights : Hash(Int32, Float32) | Nil
Constructor Detail
Class Method Detail
def self.range(min : Int32, max : Int32)
#
Creates a spec for a range of syllables with uniform distribution.
def self.weighted(weights : Hash(Int32, Float32))
#
Creates a spec for weighted syllable distribution.
Parameters
#weights
: Hash mapping syllable counts to their relative weights
Instance Method Detail
def generate_count : Int32
#