class
WordMage::WordAnalyzer
- WordMage::WordAnalyzer
- Reference
- Object
Overview
Analyzes individual words to extract phonological patterns and structure.
WordAnalyzer takes romanized words and uses a romanization map to reverse-engineer the phonemic structure, detecting syllables, clusters, hiatus sequences, and calculating complexity scores.
Example
romanization = RomanizationMap.new({
"th" => "θ", "dr" => "dr", "a" => "ɑ", "e" => "ɛ", "o" => "ɔ"
})
analyzer = WordAnalyzer.new(romanization)
analysis = analyzer.analyze("thadrae")
puts analysis.syllable_count # 2
puts analysis.clusters # ["θ", "dr"]
Defined in:
word_analyzer.crConstructors
-
.new(romanization_map : RomanizationMap)
Creates a new WordAnalyzer.
Instance Method Summary
-
#analyze(word : String, syllable_templates : Array(SyllableTemplate)) : WordAnalysis
Analyzes a romanized word using provided SyllableTemplate objects.
-
#analyze(word : String) : WordAnalysis
Analyzes a romanized word to extract phonological structure.
-
#detect_syllables(phonemes : Array(String)) : Array(Array(String))
Detects syllable boundaries in phoneme array.
Constructor Detail
Creates a new WordAnalyzer.
Parameters
romanization_map
: RomanizationMap for converting romanized text to phonemes
Instance Method Detail
Analyzes a romanized word using provided SyllableTemplate objects.
This method allows analysis to work with user-defined templates while still detecting all phonological patterns. The templates are used for context but don't modify the core analysis.
Parameters
word
: The romanized word to analyzesyllable_templates
: Array of SyllableTemplate objects (used for context)
Returns
WordAnalysis containing detailed structural information
Example
templates = [SyllableTemplate.new("CV"), SyllableTemplate.new("CVC")]
analysis = analyzer.analyze("nazagon", templates)
puts analysis.syllable_count # 3
puts analysis.consonant_count # 4
Analyzes a romanized word to extract phonological structure.
Parameters
word
: The romanized word to analyze
Returns
WordAnalysis containing detailed structural information
Example
analysis = analyzer.analyze("nazagon")
puts analysis.syllable_count # 3
puts analysis.consonant_count # 4
puts analysis.vowel_count # 3
Detects syllable boundaries in phoneme array.
Parameters
phonemes
: Array of phonemes
Returns
Array of syllables, where each syllable is an array of phonemes