Question

In: Computer Science

How would you go about writing a MATLAB program to convert a phrase in Pig Latin...

How would you go about writing a MATLAB program to convert a phrase in Pig Latin to English. I have already written a script that converts phrases from English into Pig Latin; however, I am not sure how to reverse the process. Can anyone who know's MATLAB please help me out, thank you?

P.S. I know that this is an unambigious task so it doesn't have to work completely well. With the most minor assumptions made, if it could covert for example ogday -> dog, that would be great. Thank you

Solutions

Expert Solution

Note

PigLatin is not unique in case of ‘ay’ as last character

Example 1: ogday

It can be: dog,gdo

Dog à ogday

Gdo à ogday

Example 2: ootshay

It can be hoots,shoot,tshoo

Hoots à ootshay

Shootàootshay

Tshoo àootshay

Program


str="appleway";   % PigLatin word
len=length(str);

if (str(len-2)=='w') && (str(len-1)=='a') && (str(len)=='y')
Translation=str(1:len-3)
end

if (str(len-1)=='a') && (str(len)=='y') && (str(len-2)!='w')
   i=2;

while (str(len-i)!='a') && (str(len-i)!='e') && (str(len-i)!='i') && (str(len-i)!='o') && (str(len-i)!='u')
           Translation=strcat(str(len-i:len-2),str(1:len-i-1))
      i=i+1;
end


end

OUtput

case1 :str="appleway";

Translation = apple

case 2: str="ootshay";

Translation = hoots
Translation = shoot
Translation = tshoo

case 3:str="ogday";

Translation = dog
Translation = gdo

Related Solutions

Write a program that converts an English phrase into pseudo-Pig Latin phrase (that is Pig Latin...
Write a program that converts an English phrase into pseudo-Pig Latin phrase (that is Pig Latin that doesn't allow follow all the Pig Latin Syntax rules.) Use predefined methods of the Array and String classes to do the work. For simplicity in your conversion, place the first letter as the last character in the word and prefix the characters "ay" onto the end. For example, the word "example" would become "xampleay" and "method" would become "ethodmay." Allow the user to...
for eclipse java Overview Write a program that translates an English phrase into a Pig Latin...
for eclipse java Overview Write a program that translates an English phrase into a Pig Latin phrase. Input a phrase from the user and translate it to pig latin. You can assume the phrase will be on a single line. Use at least the REQUIRED METHODS listed below, with the exact same SPELLING for method names and parameters. Input Specification The input will be an English phrase, with NO terminal punctuation. Read the phrase as a SINGLE STRING using the...
In Java.This program will translate a word into pig-latin. Pig-latin is a language game in which...
In Java.This program will translate a word into pig-latin. Pig-latin is a language game in which words in English are altered, usually by removing letters from the beginning of a word and arranging them into a suffix. The rules we will use for the pig-latin in this program are as follows: If a word starts with a consonant, split the word at the first instance of a vowel, moving the beginning consonants to the end of the word, following a...
C++ Project 6-2: Pig Latin Translator Create a program that translates English to Pig Latin. Console...
C++ Project 6-2: Pig Latin Translator Create a program that translates English to Pig Latin. Console Pig Latin Translator This program translates a sentence and removes all punctuation from it. Enter a sentence: 'Tis but a scratch. Translation:      Istay utbay away atchscray Specifications Convert the English to lowercase before translating. Remove all punctuation characters before translating. Assume that words are separated from each other by a single space. If the word starts with a vowel, just add way to the...
How do I write a COBOL program that translates a word entered into pig Latin?
How do I write a COBOL program that translates a word entered into pig Latin?
Create a program that translates English into Pig Latin. The function will take the first letter...
Create a program that translates English into Pig Latin. The function will take the first letter of each word in the sentence only if it’s a not a vowel, and place it at the end of the word followed by “ay”. Your program must be case ​ins​ ensitive. You must write the functiontranslate() ​that takes in a single English word and ​returns​ its Pig Latin translation. Remembertranslatemusttake​onlyonewordasinput.​ ############################################################# # translate() takes a single english word translates it to #pig latin...
Write a program that translates an English word into a Pig Latin word. Input ONE, and...
Write a program that translates an English word into a Pig Latin word. Input ONE, and ONLY one, word from the user, and then output its translation to Pig Latin. The rules for converting a word to Pig Latin follow. The general form for converting a word is to remove the first letter. Then append to the end of the word a hyphen, followed by the first letter that was removed, followed by "ay". For example, "robot" becomes "obot-ray" and...
How would I go about making a simple code for an analog clock using matlab?
How would I go about making a simple code for an analog clock using matlab?
Briefly describe how you would go about normalizing data
Briefly describe how you would go about normalizing data
If you were to set-up an informational interview, how would you go about this? What would...
If you were to set-up an informational interview, how would you go about this? What would be your first step? Who would you contact and why? What questions would you ask?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT