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
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