PDA

View Full Version : isthay uckssay!!


inkedmn
08-31-2002, 12:20 AM
that's right...

this is for any bot-proprietors who wish to incorporate the magic of piglatin into their creations...

now, i tested this pretty extensively, but if you have any problems, let me know


import string
import sys
import re

def pigLatin(x):
end = 'ay'
exceptions = ['sh', 'ch', 'th', 'cr', 'tr', 'wh', 'pr']
response = ''
if len(x) < 1:
print "you didn't enter anything"
sys.exit()
words = x.split(' ')
hasNumber = re.compile('\d+')
for word in words:
if hasNumber.search(word):
response += ' ' + word
elif len(word) < 3 or (len(word) == 3 and "'" in word):
response += ' ' + word + 'bay'
elif word[:2] in exceptions:
first = word[:2]
word = word[2:] + first + end
response += ' ' + word
else:
first = word[:1]
word = word[1:] + first + end
response += ' ' + word
print response.strip()

text = raw_input("enter some text: ")
pigLatin(text)


enjoy

kmj
09-11-2002, 11:54 AM
dude about qu ???

or words that end in 's ???

and are those the only exceptions? In fact, you're looking at it wrong. Those aren't exceptions at all! A piglatin translator should always chop off the part before the first vowel, and put that at the end.. then there are some exceptions to that! (like qu)..

<prescription>
Take two cookies and call me daddy^H^H^H^H^Hin the morning.
</prescription>

inkedmn
09-11-2002, 02:18 PM
i don't think piglatin is "standardized" :)

Halide
09-19-2002, 09:56 AM
i have entered the mysterious python forum... ono :plot:

kmj
09-19-2002, 12:17 PM
hehe; welcome!!!


remember; you can check out any time you like, but you can never leave!