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(Symbol, Array(String)) = Hash(Symbol, Array(String)).new, gemination_sequences : Array(String) = [] of String, vowel_lengthening_sequences : Array(String) = [] of String, phoneme_transitions : Array(Tuple(String, String)) = [] of ::Tuple(String, String), bigrams : Array(String) = [] of String, trigrams : Array(String) = [] of String)
Creates a new WordAnalysis.
- .new(pull : JSON::PullParser)
Instance Method Summary
-
#average_syllable_complexity : Float32
Returns the average syllable complexity.
-
#bigrams : Array(String)
Bigrams found in the word
-
#bigrams=(bigrams : Array(String))
Bigrams found in the word
-
#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.
-
#gemination_sequences : Array(String)
Gemination sequences found in the word
-
#gemination_sequences=(gemination_sequences : Array(String))
Gemination sequences found in the word
-
#has_clusters? : Bool
Checks if the word contains clusters.
-
#has_gemination? : Bool
Checks if the word contains gemination sequences.
-
#has_hiatus? : Bool
Checks if the word contains hiatus sequences.
-
#has_vowel_lengthening? : Bool
Checks if the word contains vowel lengthening 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(Symbol, Array(String))
Phoneme positions (initial, medial, final)
-
#phoneme_positions=(phoneme_positions : Hash(Symbol, Array(String)))
Phoneme positions (initial, medial, final)
-
#phoneme_transitions : Array(Tuple(String, String))
Phoneme transitions in the word (phoneme -> next_phoneme)
-
#phoneme_transitions=(phoneme_transitions : Array(Tuple(String, String)))
Phoneme transitions in the word (phoneme -> next_phoneme)
-
#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"])
-
#trigrams : Array(String)
Trigrams found in the word
-
#trigrams=(trigrams : Array(String))
Trigrams found in the word
-
#vowel_count : Int32
Number of vowel phonemes
-
#vowel_count=(vowel_count : Int32)
Number of vowel phonemes
-
#vowel_lengthening_sequences : Array(String)
Vowel lengthening sequences found in the word
-
#vowel_lengthening_sequences=(vowel_lengthening_sequences : Array(String))
Vowel lengthening sequences found in the word
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 positions to arrays of phonemes#gemination_sequences
: Array of gemination sequences#vowel_lengthening_sequences
: Array of vowel lengthening sequences#phoneme_transitions
: Array of phoneme transition tuples#bigrams
: Array of bigrams#trigrams
: Array of trigrams
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
Gemination sequences found in the word
Checks if the word contains clusters.
Returns
true
if the word has consonant clusters, false
otherwise
Checks if the word contains gemination sequences.
Returns
true
if the word has consonant gemination, false
otherwise
Checks if the word contains hiatus sequences.
Returns
true
if the word has vowel sequences, false
otherwise
Checks if the word contains vowel lengthening sequences.
Returns
true
if the word has vowel lengthening, false
otherwise
Phoneme positions (initial, medial, final)
Phoneme transitions in the word (phoneme -> next_phoneme)
Phoneme transitions in the word (phoneme -> next_phoneme)
Syllable patterns (e.g., ["CV", "CVC", "CV"])
Vowel lengthening sequences found in the word