class
WordMage::Analyzer
- WordMage::Analyzer
- Reference
- Object
Overview
Analyzes sets of words to extract aggregate phonological patterns.
Analyzer processes multiple words to identify statistical patterns in phoneme usage, syllable structure, complexity, and other linguistic features. The results can be used to configure generators to produce words with similar characteristics.
Example
romanization = RomanizationMap.new({
"th" => "θ", "dr" => "dr", "a" => "ɑ", "e" => "ɛ", "o" => "ɔ"
})
analyzer = Analyzer.new(romanization)
words = ["nazagon", "thadrae", "drayeki", "ora", "varanaya"]
# Basic analysis
analysis = analyzer.analyze(words)
# Analysis with Gusein-Zade smoothing
analysis = analyzer.analyze(words, use_gusein_zade_smoothing: true, smoothing_factor: 0.3)
# Analysis with templates
analysis = analyzer.with_templates(templates).analyze(words)
# Analysis with both templates and Gusein-Zade smoothing
analysis = analyzer.with_templates(templates).analyze(words, true, 0.3)
Defined in:
analyzer.crConstructors
-
.new(romanization_map : RomanizationMap)
Creates a new Analyzer.
Instance Method Summary
-
#analyze(words : Array(String), use_gusein_zade_smoothing : Bool = false, smoothing_factor : Float32 = 0.3_f32) : Analysis
Analyzes a set of words to extract aggregate patterns.
-
#with_templates(templates : Array(SyllableTemplate)) : self
Configures the analyzer to use specific syllable templates.
Constructor Detail
Creates a new Analyzer.
Parameters
romanization_map
: RomanizationMap for converting romanized text to phonemes
Instance Method Detail
Analyzes a set of words to extract aggregate patterns.
Parameters
words
: Array of romanized words to analyzeuse_gusein_zade_smoothing
: Whether to apply Gusein-Zade smoothing (default: false)smoothing_factor
: Weight of Gusein-Zade vs empirical (0.0-1.0, default: 0.3)
Returns
Analysis containing aggregate statistics and recommendations
Example
# Basic analysis
analysis = analyzer.analyze(["nazagon", "thadrae", "drayeki"])
# Analysis with Gusein-Zade smoothing
analysis = analyzer.analyze(words, true, 0.4)
# Analysis with templates
analysis = analyzer.with_templates(templates).analyze(words)
# Analysis with both templates and Gusein-Zade smoothing
analysis = analyzer.with_templates(templates).analyze(words, true, 0.3)
Configures the analyzer to use specific syllable templates.
This method allows users to provide their own SyllableTemplate objects with defined onset and coda clusters. The analysis will respect these templates while still detecting all other phonological patterns.
Parameters
templates
: Array of SyllableTemplate objects to use for analysis
Returns
Self (for method chaining)
Example
templates = [
SyllableTemplate.new("CV", allowed_clusters: ["br", "tr"]),
SyllableTemplate.new("CVC", allowed_coda_clusters: ["st", "nt"])
]
analysis = analyzer.with_templates(templates).analyze(words)