class
WordMage::WordAnalysis
- WordMage::WordAnalysis
- Reference
- Object
Overview
Represents the analysis of a single word.
WordAnalysis captures detailed information about a word's structure, including syllable patterns, phoneme counts, complexity measures, and structural features like clusters and hiatus sequences.
This class is JSON-serializable for easy storage and transmission.
Example
analysis = WordAnalysis.new(
syllable_count: 3,
consonant_count: 4,
vowel_count: 3,
hiatus_count: 1,
cluster_count: 2,
complexity_score: 8,
phonemes: ["n", "a", "z", "a", "g", "o", "n"],
syllable_patterns: ["CV", "CV", "CVC"]
)
Included Modules
- JSON::Serializable
Defined in:
word_analysis.crConstructors
-
.new(syllable_count : Int32, consonant_count : Int32, vowel_count : Int32, hiatus_count : Int32, cluster_count : Int32, complexity_score : Int32, phonemes : Array(String), syllable_patterns : Array(String), clusters : Array(String) = [] of String, hiatus_sequences : Array(String) = [] of String, phoneme_positions : Hash(String, Array(Symbol)) = Hash(String, Array(Symbol)).new)
Creates a new WordAnalysis.
- .new(pull : JSON::PullParser)
Instance Method Summary
-
#average_syllable_complexity : Float32
Returns the average syllable complexity.
-
#cluster_count : Int32
Number of consonant clusters (adjacent consonants)
-
#cluster_count=(cluster_count : Int32)
Number of consonant clusters (adjacent consonants)
-
#clusters : Array(String)
Consonant clusters found in the word
-
#clusters=(clusters : Array(String))
Consonant clusters found in the word
-
#complexity_score : Int32
Complexity score based on clusters, hiatus, and patterns
-
#complexity_score=(complexity_score : Int32)
Complexity score based on clusters, hiatus, and patterns
-
#consonant_count : Int32
Number of consonant phonemes
-
#consonant_count=(consonant_count : Int32)
Number of consonant phonemes
-
#consonant_vowel_ratio : Float32
Returns the ratio of consonants to vowels.
-
#dominant_syllable_pattern : String
Returns the most common syllable pattern.
-
#has_clusters? : Bool
Checks if the word contains clusters.
-
#has_hiatus? : Bool
Checks if the word contains hiatus sequences.
-
#hiatus_count : Int32
Number of hiatus sequences (adjacent vowels)
-
#hiatus_count=(hiatus_count : Int32)
Number of hiatus sequences (adjacent vowels)
-
#hiatus_sequences : Array(String)
Hiatus sequences found in the word
-
#hiatus_sequences=(hiatus_sequences : Array(String))
Hiatus sequences found in the word
-
#phoneme_positions : Hash(String, Array(Symbol))
Phoneme positions (initial, medial, final)
-
#phoneme_positions=(phoneme_positions : Hash(String, Array(Symbol)))
Phoneme positions (initial, medial, final)
-
#phonemes : Array(String)
Array of phonemes in the word
-
#phonemes=(phonemes : Array(String))
Array of phonemes in the word
-
#summary : String
Returns a summary of the word analysis.
-
#syllable_count : Int32
Number of syllables in the word
-
#syllable_count=(syllable_count : Int32)
Number of syllables in the word
-
#syllable_patterns : Array(String)
Syllable patterns (e.g., ["CV", "CVC", "CV"])
-
#syllable_patterns=(syllable_patterns : Array(String))
Syllable patterns (e.g., ["CV", "CVC", "CV"])
-
#vowel_count : Int32
Number of vowel phonemes
-
#vowel_count=(vowel_count : Int32)
Number of vowel phonemes
Constructor Detail
Creates a new WordAnalysis.
Parameters
#syllable_count
: Number of syllables#consonant_count
: Number of consonants#vowel_count
: Number of vowels#hiatus_count
: Number of hiatus sequences#cluster_count
: Number of consonant clusters#complexity_score
: Overall complexity score#phonemes
: Array of phonemes#syllable_patterns
: Array of syllable patterns#clusters
: Array of consonant clusters#hiatus_sequences
: Array of hiatus sequences#phoneme_positions
: Hash mapping phonemes to their positions
Instance Method Detail
Complexity score based on clusters, hiatus, and patterns
Returns the ratio of consonants to vowels.
Returns
Float32 representing the consonant-to-vowel ratio
Returns the most common syllable pattern.
Returns
String representing the most frequent syllable pattern
Checks if the word contains clusters.
Returns
true
if the word has consonant clusters, false
otherwise
Checks if the word contains hiatus sequences.
Returns
true
if the word has vowel sequences, false
otherwise
Phoneme positions (initial, medial, final)
Syllable patterns (e.g., ["CV", "CVC", "CV"])