jmlbeud ceararhtcs
jmlbeud ceararhtcs
- Subject: jmlbeud ceararhtcs
- From: Brennan <email@hidden>
- Date: Sun, 21 Sep 2003 16:49:53 +0200
I'm irgituend by rteencly plouriaespd lingistuic reeasrch wihch sowhs that
any text wehre the letrtes of idunvidail wrdos are jmlbeud is more or lses
lelgibe privdeod that the fsirt and last ceararhtcs of ecah wrod are
crrocet Longer wrods seem to sfufer msot as you can see I hvae wteitrn a
sicprt wcihh prrmofes tihs text tmrorfiaantson but I feel it cluod be
ivermpod In piaaurltcr I cn'at see a neat way of raeniting ptcuatunion
mkras Does anoyne wnat to tkae a shot at it
set str to "I'm intrigued by recently popularised linguistic
research which shows that any text where the
letters of individual words are jumbled is more or less legible,
provided that the first and last characters of each word are correct.
Longer words seem to suffer most, as you can see.
I have written a script which performs this text transformation
but I feel it could be improved. In particular, I can't see a
neat way of retaining punctuation marks. Does anyone want to
take a shot at it?"
set wds to (words of str)
set output to ""
set AppleScript's text item delimiters to ""
repeat with w in wds
set chrs to (characters of w)
set ccount to (count chrs)
set firstLetter to (character 1 of w)
set lastLetter to (character -1 of w)
set outstr to ""
if ccount < 3 then
set mixedWord to w
else
set mixStr to (characters 2 thru -2 of w)
repeat while (mixStr is not "")
set cmstr to (count mixStr)
if cmstr = 1 then
set outstr to outstr & mixStr
exit repeat
end if
set rc to (random number from 1 to cmstr)
if rc = 1 then -- take item 1
set beforeRemove to {}
set afterRemove to (items 2 thru end of mixStr)
else if rc = cmstr then
set beforeRemove to (items 1 thru -2 of mixStr)
set afterRemove to {}
else
set beforeRemove to (items 1 thru (rc - 1) of mixStr)
set afterRemove to (items (rc + 1) thru end of mixStr)
end if
set removedChar to (item rc of mixStr)
set outstr to outstr & removedChar
set mixStr to beforeRemove & afterRemove
end repeat
set mixedWord to firstLetter & outstr & lastLetter
end if
set output to (output & " " & mixedWord)
end repeat
Brennan
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.