Ancay youyay eakspay igpay atinlay? (Can you speak pig latin?) If you can’t, here are the rules: If a word begins with a consonant, take all of the letters before the first vowel and move them to the end of the word, then add ay to the end of the word. Examples: pig → igpay, there → erethay. If a word begins with a vowel (a, e, i, o, u, or y), simply add yay to the end of the word. For this problem, y is always a vowel. Examples: and → andyay, ordinary → ordinaryyay. Although there are many variants of Pig Latin (such as Kedelkloppersprook in Germany), for this problem we will always use the rules described above. A friend of yours was frustrated with everyone writing in Pig Latin and has asked you to write a program to translate to Pig Latin for him. Ouldway youyay ebay osay indkay otay oday ityay? (Would you be so kind to do it?) Inputs consist of lines of text that you will individually translate from a text file given by the user. If the file cannot be opened for some reason, output "Unable to open input file." and quit. Do not prompt the user to enter an input file name. There is no limit to the number of lines, however you must input all lines before translating. No punctuation or special characters will appear in the input. Output each line given to you translated back to the user. Needs to include "def translate(word):" for returning the word based on the pig latin rules, "def read_input(file_name):" to return a list of lines read from the file, "def parse_line(line):" to take the line given by the parameter line and split it into a list of words, running each word through the translate function and returning it as a

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Ancay youyay eakspay igpay atinlay? (Can you speak pig latin?) If you can’t, here are the rules:

If a word begins with a consonant, take all of the letters before the first vowel and move them to the end of the word, then add ay to the end of the word. Examples: pig → igpay, there → erethay.

If a word begins with a vowel (a, e, i, o, u, or y), simply add yay to the end of the word. For this problem, y is always a vowel. Examples: and → andyay, ordinary → ordinaryyay.

Although there are many variants of Pig Latin (such as Kedelkloppersprook in Germany), for this problem we will always use the rules described above.

A friend of yours was frustrated with everyone writing in Pig Latin and has asked you to write a program to translate to Pig Latin for him. Ouldway youyay ebay osay indkay otay oday ityay? (Would you be so kind to do it?)

Inputs consist of lines of text that you will individually translate from a text file given by the user. If the file cannot be opened for some reason, output "Unable to open input file." and quit.

Do not prompt the user to enter an input file name.

There is no limit to the number of lines, however you must input all lines before translating. No punctuation or special characters will appear in the input.

Output each line given to you translated back to the user.

Needs to include "def translate(word):" for returning the word based on the pig latin rules, "def read_input(file_name):" to return a list of lines read from the file, "def parse_line(line):" to take the line given by the parameter line and split it into a list of words, running each word through the translate function and returning it as a translated string, "def parse_all_lines(lines):" that returns a new list of lines where each line is translated and running each line through the parse_line function.  

Finally, it is tested with 

"if __name__ == "__main__":
file_name = input()
lines = read_input(file_name)
if len(lines) == 0:
print("Unable to open input file.")
else:
for line in parse_all_lines(lines):
print(line)"

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY