Forum: Ruby Re: Substituting from another file

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
67bb4df2775f6a6b603347dce7119571?d=identicon&s=25 unknown (Guest)
on 2006-04-12 15:49
(Received via mailing list)
I had resolved a similar problem some time ago by reading what
corresponds
to your dictionary data into a hash (i.e.,  {'PANELED' =>'P AE1 N  AH0 L
D',
'PANELING'=>"P AE1 N AH0 L IH0 NG"} ).
I would then replace  the keys by the values in the target text using
gsub.
Cave: actually, in my application, I also had to sort my keys for
length,  in
case
a word would be longer than another, but pronounced identically ...  you
can do that by iterating over an array which you get from  my_hash.sort.

Best regards,

Axel
This topic is locked and can not be replied to.