class WordMage::WordAnalysis

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

Defined in:

word_analysis.cr

Constructors

Instance Method Summary

Constructor Detail

def self.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.

Parameters


[View source]
def self.new(pull : JSON::PullParser) #

[View source]

Instance Method Detail

def average_syllable_complexity : Float32 #

Returns the average syllable complexity.

Returns

Float32 representing complexity per syllable


[View source]
def cluster_count : Int32 #

Number of consonant clusters (adjacent consonants)


[View source]
def cluster_count=(cluster_count : Int32) #

Number of consonant clusters (adjacent consonants)


[View source]
def clusters : Array(String) #

Consonant clusters found in the word


[View source]
def clusters=(clusters : Array(String)) #

Consonant clusters found in the word


[View source]
def complexity_score : Int32 #

Complexity score based on clusters, hiatus, and patterns


[View source]
def complexity_score=(complexity_score : Int32) #

Complexity score based on clusters, hiatus, and patterns


[View source]
def consonant_count : Int32 #

Number of consonant phonemes


[View source]
def consonant_count=(consonant_count : Int32) #

Number of consonant phonemes


[View source]
def consonant_vowel_ratio : Float32 #

Returns the ratio of consonants to vowels.

Returns

Float32 representing the consonant-to-vowel ratio


[View source]
def dominant_syllable_pattern : String #

Returns the most common syllable pattern.

Returns

String representing the most frequent syllable pattern


[View source]
def has_clusters? : Bool #

Checks if the word contains clusters.

Returns

true if the word has consonant clusters, false otherwise


[View source]
def has_hiatus? : Bool #

Checks if the word contains hiatus sequences.

Returns

true if the word has vowel sequences, false otherwise


[View source]
def hiatus_count : Int32 #

Number of hiatus sequences (adjacent vowels)


[View source]
def hiatus_count=(hiatus_count : Int32) #

Number of hiatus sequences (adjacent vowels)


[View source]
def hiatus_sequences : Array(String) #

Hiatus sequences found in the word


[View source]
def hiatus_sequences=(hiatus_sequences : Array(String)) #

Hiatus sequences found in the word


[View source]
def phoneme_positions : Hash(String, Array(Symbol)) #

Phoneme positions (initial, medial, final)


[View source]
def phoneme_positions=(phoneme_positions : Hash(String, Array(Symbol))) #

Phoneme positions (initial, medial, final)


[View source]
def phonemes : Array(String) #

Array of phonemes in the word


[View source]
def phonemes=(phonemes : Array(String)) #

Array of phonemes in the word


[View source]
def summary : String #

Returns a summary of the word analysis.

Returns

String with key analysis metrics


[View source]
def syllable_count : Int32 #

Number of syllables in the word


[View source]
def syllable_count=(syllable_count : Int32) #

Number of syllables in the word


[View source]
def syllable_patterns : Array(String) #

Syllable patterns (e.g., ["CV", "CVC", "CV"])


[View source]
def syllable_patterns=(syllable_patterns : Array(String)) #

Syllable patterns (e.g., ["CV", "CVC", "CV"])


[View source]
def vowel_count : Int32 #

Number of vowel phonemes


[View source]
def vowel_count=(vowel_count : Int32) #

Number of vowel phonemes


[View source]