Y as Consonant vs. Y as Vowel

Mar 29, 2012 at 5:17pm
Hey all.

I have written a program that takes sentences in English and translates them to Pig Latin. However, the only thing I cannot figure out is how to write code that determines whether 'y' is being used as a vowel (my) or as a consonant (y). I need to write some kind of rule that translates y differently based on what it is. Any suggestions would be great!
Last edited on Mar 30, 2012 at 2:06pm
Mar 29, 2012 at 5:39pm
Determine what context Y is being used in (compare to immediate surrounding characters) - that's how I would do it. I am unfamiliar with the language though so I can not help you, maybe look up the rules of the language to determine these conditions?
Mar 29, 2012 at 6:34pm
The problem is that y is not always surrounded by particular letters when it is used as a vowel in English, so I'm not really sure how I can define a rule.

Pig Latin with a y would be as the following:

As a consonant, yellow -> ellowyay
As a vowel, style -> ylestay
Last edited on Mar 29, 2012 at 6:35pm
Mar 29, 2012 at 6:39pm
I don't know if this is always the case, but 99% of the time, in English, Y as the very first letter in a word is a consonant (yellow) and Y as the very last letter is a vowel (ugly)

Another way to check would be to look at the surrounding letters and see if any of them are vowels. Y next to another vowel = Y is likely a consonant. Y next to only consonants, Y = likely a vowel. The only exception to this rule that I can think of offhand is "eye", where is is surrounded by vowels but is also a vowel.


EDIT: actually... is consonant Y ever not at the start of the word? Maybe it's as simple as start of word = consonant, not start of word = vowel? That seems too simple but I can't immediately think of any words that don't follow that pattern.

EDIT again: derp. No it doesn't work at all. "way", "play", etc are all consonants. Grumble grumble.
Last edited on Mar 29, 2012 at 6:43pm
Mar 29, 2012 at 11:49pm
Gah, the 'y' part is proving more difficult than writing the rest of the code hahaha. Can't figure out any rule that is constant! >.<
Mar 29, 2012 at 11:55pm
the "adjacent to a vowel" rule seems like it might be the way to go. If the Y is next to only consonants, it's a vowel... but if it's next to any vowels, it's a consonant.

The only exception I can think of is still "eye", but it seems to be true for every other word I can think of.
Mar 30, 2012 at 1:01am
Haha don't you love English? I can't imagine trying to learn this language as a second language
Mar 30, 2012 at 1:04am
But I found this link. Seems to useful, though programming these rules seems like a pain. Best of luck towards to you
http://www.decoz.com/Y_vowel-consonant.htm
Mar 30, 2012 at 1:10am
Pig Latin only cares about sounds. Treat Y as a vowel.
Mar 30, 2012 at 2:31am
Can't have Y always as a vowel. What about the word "yellow"? Wouldn't make sense to force it that way.
Mar 30, 2012 at 5:07am
Y as first letter = consonant, otherwise vowel?

That should work as far as pig-latin is concerned
Mar 30, 2012 at 12:37pm
Mar 30, 2012 at 1:09pm
Always interesting when you find someone with the same teacher posting on here.
Mar 30, 2012 at 2:08pm
I believe I have compiled a code that can determine whether the y is being used as consonant or vowel based on the letters around it. Once I test it, I will come back and post whether it works! :) Thanks for the help/suggestions.
Mar 30, 2012 at 3:54pm
@Spikes6669
That is very common.
Topic archived. No new replies allowed.