Class: Phrase::Pronunciations
- Inherits:
-
Object
- Object
- Phrase::Pronunciations
- Defined in:
- lib/ruby_rhymes.rb,
lib/syllable_arrays.rb
Overview
Pronunciations does the heavy lifting, interfacing with the mythical text file of doom
Constant Summary collapse
- WORDS_PATH =
"words.txt"
- RHYMES_PATH =
"rhymes.txt"
- MULTIPLES_PATH =
"multiple.txt"
- SYBSYL =
[ /cial/, /tia/, /cius/, /cious/, /uiet/, /gious/, /geous/, /priest/, /giu/, /dge/, /ion/, /iou/, /sia$/, /.che$/, /.ched$/, /.abe$/, /.ace$/, /.ade$/, /.age$/, /.aged$/, /.ake$/, /.ale$/, /.aled$/, /.ales$/, /.ane$/, /.ame$/, /.ape$/, /.are$/, /.ase$/, /.ashed$/, /.asque$/, /.ate$/, /.ave$/, /.azed$/, /.awe$/, /.aze$/, /.aped$/, /.athe$/, /.athes$/, /.ece$/, /.ese$/, /.esque$/, /.esques$/, /.eze$/, /.gue$/, /.ibe$/, /.ice$/, /.ide$/, /.ife$/, /.ike$/, /.ile$/, /.ime$/, /.ine$/, /.ipe$/, /.iped$/, /.ire$/, /.ise$/, /.ished$/, /.ite$/, /.ive$/, /.ize$/, /.obe$/, /.ode$/, /.oke$/, /.ole$/, /.ome$/, /.one$/, /.ope$/, /.oque$/, /.ore$/, /.ose$/, /.osque$/, /.osques$/, /.ote$/, /.ove$/, /.pped$/, /.sse$/, /.ssed$/, /.ste$/, /.ube$/, /.uce$/, /.ude$/, /.uge$/, /.uke$/, /.ule$/, /.ules$/, /.uled$/, /.ume$/, /.une$/, /.upe$/, /.ure$/, /.use$/, /.ushed$/, /.ute$/, /.ved$/, /.we$/, /.wes$/, /.wed$/, /.yse$/, /.yze$/, /.rse$/, /.red$/, /.rce$/, /.rde$/, /.ily$/, /.ely$/, /.des$/, /.gged$/, /.kes$/, /.ced$/, /.ked$/, /.med$/, /.mes$/, /.ned$/, /.sed$/, /.nce$/, /.rles$/, /.nes$/, /.pes$/, /.tes$/, /.res$/, /.ves$/, /ere$/ ]
- ADDSYL =
[ /ia/, /riet/, /dien/, /ien/, /iet/, /iu/, /iest/, /io/, /ii/, /ily/, /.oala$/, /.iara$/, /.ying$/, /.earest/, /.arer/, /.aress/, /.eate$/, /.eation$/, /[aeiouym]bl$/, /[aeiou]{3}/, /^mc','ism/, /^mc','asm/, /([^aeiouy])\1l$/, /[^l]lien/, /^coa[dglx]./, /[^gq]ua[^auieo]/, /dnt$/ ]
- EXCEPTIONS_ONE =
UBER EXCEPTIONS - WHOLE WORDS THAT SLIP THROUGH THE NET OR SOMEHOW THROW A WOBBLY
[ /abe/, /ace/, /ade/, /age/, /ale/, /are/, /use/, /ate/ ]
- @@PRONUNCIATIONS =
Pronunciation ID => Pronunciation
{}
- @@MULTIPLE_PRONUNCIATIONS =
Word => Pronunciations
{}
- @@RHYMES =
Rhyme key => Pronunciations
{}
- @@LOADED =
false
Class Method Summary collapse
- .get_pronunciations(word) ⇒ Object
-
.get_rhymes(pronunciation) ⇒ Object
Returns arrays of rhymes – an Array of rhymes for each pronunciation.
Class Method Details
.get_pronunciations(word) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/ruby_rhymes.rb', line 96 def self.get_pronunciations(word) load pronunciations = @@MULTIPLE_PRONUNCIATIONS[word] if pronunciations != nil # Multiple pronunciations case return pronunciations else # Single or pronunciation case pronunciation = get_pronunciation(word) if pronunciation return [pronunciation] else return [Pronunciation.new(word, nil, auto_syllables(word.downcase), nil)] end end end |
.get_rhymes(pronunciation) ⇒ Object
Returns arrays of rhymes – an Array of rhymes for each pronunciation
112 113 114 115 116 117 118 |
# File 'lib/ruby_rhymes.rb', line 112 def self.get_rhymes(pronunciation) load rhymes = [] rhymes = @@RHYMES[pronunciation.rhyme_key] rhymes.delete(pronunciation) rhymes end |