Phonetically Morphing Symbols
I have been learning Spanish lately.
People say learning Spanish is easy. I disagree. I am glad that I learned German half my life ago, otherwise I would feel at this point that I'm just not cut out to learn a "foreign" language. I find Spanish at least as difficult to master as German. Perhaps because I am a native English speaker, and English is a Germanic language (not a Latin-based, "romance" language).
At any rate, one of the roadblocks to speaking Spanish correctly is that the pronunciation, while much more internally consistent than English, differs significantly from that of my mother tongue ("h" is always silent, "J" is pronounced as "h", etc.). As an aid to visualize how Spanish text should be pronounced, I wrote a method that receives Spanish text and returns the phonetic equivalent.
The code is this:
private string getPhoneticSpanish(string spanTxt)
{
String spanishText = spanTxt;
spanishText = spanishText.Replace("cc", "ks");
spanishText = spanishText.Replace("ll", "y");
spanishText = spanishText.Replace("H", string.Empty);
spanishText = spanishText.Replace("ch", "CH");
spanishText = spanishText.Replace("h", string.Empty);
spanishText = spanishText.Replace("que", "kay");
spanishText = spanishText.Replace("e", "A");
spanishText = spanishText.Replace(" y ", " E ");
spanishText = spanishText.Replace("i", "E");
spanishText = spanishText.Replace("j", "h");
spanishText = spanishText.Replace("ñ", "ny");
spanishText = spanishText.Replace("q", "k");
spanishText = spanishText.Replace("u", "oo");
spanishText = spanishText.Replace("z", "s");
spanishText = spanishText.Replace("c", "k");
spanishText = spanishText.Replace("ke", "se");
spanishText = spanishText.Replace("ki", "si");
spanishText = spanishText.Replace("ge", "h");
spanishText = spanishText.Replace("gi", "h");
spanishText = spanishText.Replace("CH", "ch");
return spanishText;
}
...and you can call it like so:
string spanishText = "Hablo mucho. . .";
MessageBox.Show(getPhoneticSpanish(spanishText));
So, if you pass this text (from here):
Huckleberry Finn comienza donde se quedaron las cosas después de Las Aventuras de Tom Sawyer. Huck y Tom Sawyer se habían hecho ricos por todo el tesoro que descubrieron y la Viuda Douglas adoptó a Huck. Ella trata de civilizar a Huck en muchas formas diferentes, incluyendo darle ropa limpia y nueva, enseñándole acerca de Dios y la Biblia, y tratando de educarlo en cosas como la escritura y la lectura. La hermana de la Viuda Douglas, la Señorita Watson, incluso tratar de ayudar. Huck no se sienten cómodo con sus costumbres civilizadas, él sólo quiere estar con sus trapos viejos y fumar.
...this is what is returned:
It looks like some sort of haywire Finnish dialect, but it's really American English-ized Mexican Spanish.
This snippet can no doubt be improved; feel free to do so, and post your improvements back here or email them to me at b clay shannon (all one word) at att dot net