Well, the simple regex based one-liner seems to have gotten
plenty of airplay, so I decided to expand mine in an attempt
to improve the readability of the munged text. For example:
A naive munging:
Noumeurs idavilundis have dneoatrstmed the ieneascrd
dfifclutiy oinrcrucg wehn leihngter wdors are slipmy
reiondmazd. Raionizdnmg wiihtn hntyahoeipn buadoreins
offers smoe irnmoeemvpt.
A slightly more readable munging:
Nuemruos inididvuals hvae dnometrtsaed the insecraed
dfiifulcty ocucrinrg when lghetnier wrods are smiply
rnamodized. Randomzinig wihtin hyphenatoin bonduiares
offres some imvoepremnt.
Original text:
Numerous individuals have demonstrated the increased
difficulty occurring when lengthier words are simply
randomized. Randomizing within hyphenation boundaries
offers some improvement.
The hyphen-boundary randomizer:
require 'text/hyphen'
hyp = Text::Hyphen.new :left => 1, :right => 1
text = ARGF.read
text.gsub!(/[^\W\d_]+/) do |m|
hyp.visualize(m).split(/(^\w|\w$)|-/).map{|t|
t.split(//).sort_by{rand}.join
}.join
end
puts text
__END__
cheers,
andrew
--
Posted via http://www.ruby-forum.com/.