• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Nice Automator article on O'Reilly
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Nice Automator article on O'Reilly


  • Subject: Re: Nice Automator article on O'Reilly
  • From: David Marshall <email@hidden>
  • Date: Sat, 7 May 2005 00:08:52 -0400

"Gary (Lists)" wrote:

Sloppy, poor Pig Grammar and no punctuation but funny, nonetheless.

The punctuation, though essential to a polished project, is too tedious to contemplate at the moment.


I'm not sure of the formal syntax of Pig Latin; the way I learned it, words beginning with vowels are translated with "way" appended: "asparagus" --> "asparagusway" (notice that I also omit the "-" prior to the suffix). I translate words with fewer than 3 letters, too, but I'll accept your exclusion of "the." :-)

- - - - -

--> lots of line wrapping here

property vowels : {"a", "e", "i", "o", "u"}
property noPig : {"the"}
set AppleScript's text item delimiters to ""
set mySentence to text returned of (display dialog "text to parse:" & return & return default answer "")
-->"Yvan answered Yes to Qatar Street question"
set myWords to words of mySentence
set pigWords to {}
repeat with aWord in myWords
if (aWord is not in noPig) then
set aWord to parseChars(aWord)
end if
copy aWord & " " to end of pigWords
end repeat
set pigSentence to characters 1 thru -2 of (pigWords as text) as text
display dialog "\"" & mySentence & "\"" & " in Pig Latin is " & "\"" & pigSentence & "\""
-->"Yvanway answeredway esYay otay atarQay eetStray estionquay"


on parseChars(thisWord)
set firstChar to first character of thisWord
ignoring case
if firstChar is "y" then
if second character of thisWord is in vowels then
set wordOut to (characters 2 thru end of thisWord as text) & firstChar & "ay"
else
set wordOut to thisWord & "way"
end if
else
if firstChar is "q" then
if second character of thisWord is "u" then
set wordOut to (characters 3 thru end of thisWord as text) & firstChar & "uay"
else
set wordOut to (characters 2 thru end of thisWord as text) & firstChar & "ay"
end if
else
if firstChar is in vowels then
set wordOut to thisWord & "way"
else
set wordOut to parseConsonants(thisWord) & "ay"
end if
end if
end if
end ignoring
end parseChars


on parseConsonants(subWord)
  set subWord to characters of subWord
  if second item of subWord is in vowels then
    return (rest of subWord & first item of subWord) as text
  else
    set thisSubWord to (rest of subWord & first item of subWord) as text
    parseConsonants(thisSubWord)
  end if
end parseConsonants

- - - - -

Dave

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: new todo in iCal
  • Next by Date: Re: move all files also with no extension via shell command
  • Previous by thread: Re: Nice Automator article on O'Reilly
  • Next by thread: Re: Nice Automator article on O'Reilly
  • Index(es):
    • Date
    • Thread