[Tutor] A string-manipulation question

HouseScript at comcast.net HouseScript at comcast.net
Mon Apr 2 17:19:45 CEST 2007


>>The only "hitch" I see is how one tells that an initial 
>>consonant is a vowel sound or not. (honor vs home)?

The above is exactly what I was thinking about, theres no way I could think of besides creating a dict for the few thousand English words that have this trait.  Then run a search against the dict (the one for words like honor), then something like if the words on this list then just add ay to the end of the word and jump to the next word in the sequence.  And if the word's not on that list then just following the regular pig latin rules.

I apologize if what I'm saying doesn't make too much sense.  I've been teaching myself python for all of 3 weeks.  Its been long days and even longer nights of pure confusion at some times...but only because I NEED to know everything I can.  Imaginary numbers blew my mind lol.

-------------- Original message -------------- 
From: Bob Gailer <bgailer at alum.rpi.edu> 

> HouseScript at comcast.net wrote: 
> > Alan Gilfoy wrote: 
> > 
> > > Is there a way in Python to separate a string into its component words. 
> > you could do something like this: 
> > >>> x = Is there a way in Python to seperate a string into its 
> > compontent words. 
> > >>> x.split() 
> > that would yield: 
> > ['Is', 'there', 'a', 'way', 'in', 'Python', 'to', 'separate', 'a', 
> > 'string', 'into', 'its', 'component', 'words.'] 
> > As far as teh translating to pig latin.....well I honestly don't know. 
> From Wikipedia, the rules are: 
> 
> 1. For words that begin with consonant 
> sounds, move the initial 
> consonant or consonant cluster 
> to the end of the 
> word and add "ay." Examples: 
> * fatso → atso-fay 
> * button → /utton-bay/ 
> * star → /ar-stay/ 
> * three → /ee-thray/ 
> * question → /estion-quay/ 
> 2. For words that begin with vowel 
> sounds (including silent 
> consonants ), simply 
> add the syllable "ay" to the end of the word. 
> * eagle → /eagle-ay/ 
> * America → /America-ay/ 
> * honor → /honor-ay/ 
> 
> Seems pretty straightforward to translate to Python (or any other 
> language). The only "hitch" I see is how one tells that an initial 
> consonant is a vowel sound or not. (honor vs home)? 
> 
> opehay isthay elphay 
> 
> -- 
> Bob Gailer 
> 510-978-4454 
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070402/a7e30277/attachment.htm 


More information about the Tutor mailing list