class WordMage::WordAnalyzer

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.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(romanization_map : RomanizationMap) #

Creates a new WordAnalyzer.

Parameters

  • romanization_map: RomanizationMap for converting romanized text to phonemes

[View source]

Instance Method Detail

def analyze(word : String) : WordAnalysis #

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

[View source]