Computers and Technology

In this problem, you will write a translation program. First your program will prompt the user for three filenames. The first file is a dictionary. Each line contains a regular English word followed immediately by a vertical bar ($\verb#|#$) followed immediately by the word or phrase that the word should be translated to. For example, if I wanted to translate $\verb#'hello'#$ as $\verb#'hola'#$, one entry in the file would be $\verb#hello|hola#$. The second file should contain a text to translate. You may assume that words in this file are separated by spaces and that there is no other punctuation (including periods at the ends of sentences). The last filename should be for an output file. The program will then take each word in the input file and translate it based on the dictionary. In other words, if the word appears on the left side of a bar in the dictionary file, the program will replace it with whatever is on the right side of the bar. If the word does not appear on the left side of a bar, it is kept as is in the output. (Note, though, that you do not have to preserve case in the output---if a word is capitalized in the input, it does not have to be capitalized in the output.) All the words should be written to the output file. Other than prompting for the filenames, there should be no other output to the IDLE shell.

For example, using the provided files $\verb#pirateWords. txt#$ and $\verb#myInput. txt#$, a run of your program could look like this:
Enter name of dictionary: pirateWords. txt
Enter name of text to translate: myInput. txt
Enter name of output file: myOutput. txt

There should be nothing printed, and the contents of $\verb#myOutput. txt#$ would be:
avast i have come to swipe ye filthy lucre
ye filthy lucre or ye life

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 12:30, gerardoblk5931
An atom's diameter is about 0.1 nanometer (1Ă—10-9m), and a human hair is about 1Ă—10-3m. how many times greater is a human hair than an atom's diameter? sorry pushed wronf button but this is math
Answers: 3
image
Computers and Technology, 22.06.2019 21:00, jennifer7037
Ulia is planning to attend the same private four-year college her parents attended. she wants to save at least $18,000 in four years to contribute to her college education. which monthly deposit amounts can julia use to achieve her goal? check all that apply.
Answers: 2
image
Computers and Technology, 23.06.2019 12:20, jshhs
When guido van rossum created python, he wanted to make a language that was more than other programming languages. a. code-based b. human-readable c. complex d. functional
Answers: 1
image
Computers and Technology, 23.06.2019 17:30, granta1
Write pseudocode to represent the logic of a program that allows the user to enter a value. the program multiplies the value by 10 and outputs the result.
Answers: 1
Do you know the correct answer?
In this problem, you will write a translation program. First your program will prompt the user for t...

Questions in other subjects:

Konu
Chemistry, 05.04.2020 05:21