Class: Phoneme
- Inherits:
-
Object
- Object
- Phoneme
- Defined in:
- lib/phoneme.rb
Overview
Instance Attribute Summary collapse
-
#to_s ⇒ Object
readonly
Returns the value of attribute to_s.
Instance Method Summary collapse
-
#initialize(s) ⇒ Phoneme
constructor
A new instance of Phoneme.
Constructor Details
#initialize(s) ⇒ Phoneme
Returns a new instance of Phoneme.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/phoneme.rb', line 16 def initialize(s) @a = [ {ey: /^a.[eo]/, ae: /^a.*/ }, :b, {k: /^ca/, ch: /^(ch)/,s: /^ce|^c.*/}, :d, {iy: /^ee|^e$/, eh: /^e.*/}, :f, {jh: /^ge/, g: /^g.*/}, {hh: /^h./}, {ay: /^i$|^ie|^igh|^i.e/, ih: /^i.*/}, :jh, {n: /^kn/, k: /^k.*/}, :l, {m: /^(me)|^m/}, {ng: /^ng/, n: /^n.*/}, {ow: /^oa|^o$/, oy: /^oy/, aw: /^(ou)/, ah: /^om|^pl/}, {p: /^p.*/}, :q, :r, {sh: /^(sh)/, s: /^s.*/}, {th: /^(th)/, t: /^t.*/}, {uw: /^(u)b|^(u)de/, er: /^(ur)/, uh: /^u.*/}, :v, {w: /^(wh)|^w.*/}, {z: /^xy/, e: /^x.*/}, {zh: /^zu/, z: /^z.*/} ] @to_s = phonemize(s).sub(/(e|iy) $/,'').rstrip.upcase end |
Instance Attribute Details
#to_s ⇒ Object (readonly)
Returns the value of attribute to_s.
14 15 16 |
# File 'lib/phoneme.rb', line 14 def to_s @to_s end |