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!
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?
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
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.
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.
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.