dink87522 Posted July 12, 2009 Share Posted July 12, 2009 What I have here is more of a logic problem that I can't get my head around than a programming problem. I am trying to program an English to Pig Latin translator. I've got the English to Pig Latin part down and its working great. The part I am having difficulty with is the Pig Latin to English part. Say I have the word ellohay (hello) which I wish to convert into English. The first thing I am doing is removing the added ay at the end and the new word becomes elloh. This is where I have the problem. I have to somehow identify which letters to remove from the end and add back to the front of the word (i.e. h needs to be removed and added back to the front). However with a word such as string which translates as ingstray, when we remove the ay we are left with ingstr, and need to identify that str needs to be removed and added back on the front. I am lost as to how to identify which characters need to be removed to be re-added to the front and can't find a common rule to program by. There are translators out there already like this, so it works somehow, I just need a push in the right direction i think Quote Link to comment https://forums.phpfreaks.com/topic/165673-string-manipulation/ Share on other sites More sharing options...
trq Posted July 12, 2009 Share Posted July 12, 2009 What you need is a list of rules. I have no idea what pig latin is so can't help you, but I'd start by searching for some type of definition of the language. Quote Link to comment https://forums.phpfreaks.com/topic/165673-string-manipulation/#findComment-873929 Share on other sites More sharing options...
dink87522 Posted July 12, 2009 Author Share Posted July 12, 2009 If a word begins with a vowel, append "ay" to the end. I.e. Apple becomes appleay. If a word begins with a consonant, all the conosnants up to the first vowel are removed and appended to the end of the word, after which ay is also added. I.e. House becomes ousehay I.e Prince becomes incepray I.e. String becomes ingstray I can't work out a rule to go from pig latin back to english. Removing the ay is easy, however I can't work out whether to append 1, 2, 3, x consonants to the front of the word (i.e. look at instray). Quote Link to comment https://forums.phpfreaks.com/topic/165673-string-manipulation/#findComment-873930 Share on other sites More sharing options...
ignace Posted July 12, 2009 Share Posted July 12, 2009 Create an association table: ingstr=string ouseh=house incepr=prince Remove the ay and then query your db. As you can't identify how many need to be removed from the end and prepended. Quote Link to comment https://forums.phpfreaks.com/topic/165673-string-manipulation/#findComment-873967 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.