Re: jmlbeud ceararhtcs
Re: jmlbeud ceararhtcs
- Subject: Re: jmlbeud ceararhtcs
- From: "Arthur J. Knapp" <email@hidden>
- Date: Mon, 22 Sep 2003 10:57:57 -0400
>
Date: Sun, 21 Sep 2003 16:49:53 +0200
>
From: Brennan <email@hidden>
>
Subject: jmlbeud ceararhtcs
>
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
This is quite possibly the most fascinating message I have ever read on
this list. :)
>
In piaaurltcr I cn'at see a neat way of raeniting ptcuatunion
>
mkras Does anoyne wnat to tkae a shot at it
--> "I'll tkae a satb at it!!!"
property ksUpper : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
property ksLower : "abcdefghijklmnopqrstuvwxyz"
property ksAlpha : ksUpper & ksLower
--
property kcAsc1 : ASCII character 1
on BreakAtWords(s)
set tids to AppleScript's text item delimiters
repeat with i from 1 to ksAlpha's length
set AppleScript's text item delimiters to ksAlpha's character i
set s to s's text items --> only safe for small s
set AppleScript's text item delimiters to ,
kcAsc1 & ksAlpha's character i & kcAsc1 -- "~A~"
set s to s as string
end repeat
-- ie: "www.tmbg.com, dude!"
--> "~w~~w~~w~.~t~~m~~b~~g~.~c~~o~~m~, ~d~~u~~d~~e~!"
set AppleScript's text item delimiters to kcAsc1 & kcAsc1
set s to s's text items
--> { "~w", "w", "w~.~t", "m", "b", "g~.~c", "o", "m~, ~d", "u", "d",
"e~!"
set AppleScript's text item delimiters to ""
set s to s as string
--> "~www~.~tmbg~.~com~, ~dude~!"
set AppleScript's text item delimiters to kcAsc1
set s to s's text items
--> { "", "www", ".", "tmbg", ".", "com", ", ", "dude", "!" }
set AppleScript's text item delimiters to tids
return s --> Even items are words, odd items are not.
end BreakAtWords
on BrennanWordTransformation(w)
if (w's length < 4) then
return w
else
set chars to w's characters 2 thru -2
set len to chars's length
repeat (len div 2) times
set i to SomeIndex(len)
set j to SomeIndex(len)
set t to chars's item i
set chars's item i to chars's item j
set chars's item j to t
end repeat
return w's character 1 & chars & w's character -1
end if
end BrennanWordTransformation
on newIntegerList(l, r)
script o
property p : {}
end script
if (l > r) then set {l, r} to {r, l}
repeat with i from l to r
set o's p's end to i
end repeat
return o's p
end newIntegerList
property maxSomeIndex : 50
property someIndexList : newIntegerList(1, maxSomeIndex)
on SomeIndex(forLength) --> forLength must be < maxSomeIndex
return some item of someIndexList's items 1 thru forLength
end SomeIndex
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 evenWords to BreakAtWords(str)
repeat with i from 2 to evenWords's length by 2 --> process words
set evenWords's item i to BrennanWordTransformation(evenWords's item i)
end repeat
set newStr to evenWords as string
It's pretty fast, though a few improvments in speed could be made,
and protection for very large strings could also be implemented via
Has's everyTextItem() handler:
<
http://www.barple.pwp.blueyonder.co.uk/libraries/EveryItemLibFolder.hqx>
Wow, scripting is just like riding a bicycle... you never forget how,
no matter how hard you try....
{ Arthur Knapp, of <
http://www.STELLARViSIONs.com>
a r t h u r @ s t e l l a r v i s i o n s . c o m
"I'm the Green Fairy. The hills are alive...!"
}
_______________________________________________
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.