NOTE: You have not given instructions for encode, so I have not done it. Moreover the example given for cat is incorrect. So, I have taken other example."
Code is here and screenshots are provided below for help:
braille_table={"a":[[1,0],[0,0],[0,0]],
"b":[[1,0],[1,0],[0,0]],
"c":[[1,1],[0,0],[0,0]],
"d":[[1,1],[0,1],[0,0]],
"e":[[1,0],[0,1],[0,0]],
"f":[[1,1],[1,0],[0,0]],
"g":[[1,1],[1,1],[0,0]],
"h":[[1,0],[1,1],[0,0]],
"i":[[0,1],[1,0],[0,0]],
"j":[[0,1],[1,1],[0,0]],
"k":[[1,0],[0,0],[1,0]],
"l":[[1,0],[1,0],[1,0]],
"m":[[1,1],[0,0],[1,0]],
"n":[[1,1],[0,1],[1,0]],
"o":[[1,0],[0,1],[1,0]],
"p":[[1,1],[1,0],[1,0]],
"q":[[1,1],[1,1],[1,0]],
"r":[[1,0],[1,1],[1,0]],
"s":[[0,1],[1,0],[1,0]],
"t":[[0,1],[1,1],[1,0]],
"u":[[1,0],[0,0],[1,1]],
"v":[[1,0],[1,0],[1,1]],
"w":[[0,1],[1,1],[0,1]],
"x":[[1,1],[0,0],[1,1]],
"y":[[1,1],[0,1],[1,1]],
"z":[[1,0],[0,1],[1,1]]}
def decode(file_name):
f1=open(file_name,"r")
Lines=f1.readlines()
word=""
for line in Lines:
l1=[]
l2=[]
l3=[]
l4=[]
for i in
range(0,2):
l1.append(int(line[i]))
for i in
range(2,4):
l2.append(int(line[i]))
for i in
range(4,6):
l3.append(int(line[i]))
l4=[l1,l2,l3]
for letter,key in
braille_table.items():
if key==l4:
word+=letter
return word
file_name=input("Enter file name: ")
plain_text=decode(file_name)
print(plain_text)
screenshots of code with comments:
text file used for example
output of code
Please give your feedback
Using the template code provided in the braille translator.py file as a starting point, complete functions...
A. File I/O using C library functions File I/O in C is achieved using a file pointer to access or modify files. Processing files in C is a four-step process: o Declare a file pointer. o Open the desired file using the pointer. o Read from or write to the file and finally, o Close the file. FILE is a structure defined in <stdio.h>. Files can be opened using the fopen() function. This function takes two arguments, the filename and...
Preliminaries Download the template class and the driver file. Objective Learn how to traverse a binary search tree in order. Description For the template class BinarySearchTree, fill in the following methods: insert - Inserts values greater than the parent to the right, and values lesser than the parent to the left.parameters elem - The new element to be inserted into the tree. printInOrder - Prints the values stored in the tree in ascending order. Hint: Use a recursive method to...
Language: C Write an encoder and a decoder for a modified "book cipher." A book cipher uses a document or book as the cipher key, and the cipher itself uses numbers that reference the words within the text. For example, one of the Beale ciphers used an edition of The Declaration of Independence as the cipher key. The cipher you will write will use a pair of numbers corresponding to each letter in the text. The first number denotes the...
Language: C Write an encoder and a decoder for a modified "book cipher." A book cipher uses a document or book as the cipher key, and the cipher itself uses numbers that reference the words within the text. For example, one of the Beale ciphers used an edition of The Declaration of Independence as the cipher key. The cipher you will write will use a pair of numbers corresponding to each letter in the text. The first number denotes the...
For this assignment, you will write a program to work with Huffman encoding. Huffman code is an optimal prefix code, which means no code is the prefix of another code. Most of the code is included. You will need to extend the code to complete three additional methods. In particular, code to actually build the Huffman tree is provided. It uses a data file containing the frequency of occurrence of characters. You will write the following three methods in the...
- Complete the code to solve a maze- Discuss related data structures topicsProgramming-----------In this part, you will complete the code to solve a maze.Begin with the "solveMaze.py" starter file.This file contains comment instructions that tell you where to add your code.Each maze resides in a text file (with a .txt extension).The following symbols are used in the mazes:BARRIER = '-' # barrierFINISH = 'F' # finish (goal)OPEN = 'O' # open stepSTART = 'S' # start stepVISITED = '#' #...
In a new file located in the same package as the class Main, create a public Java class to represent a photograph that consists of a linear (not 2D) array of pixels. Each pixel is stored as an integer. The photograph class must have: (a) Two private fields to represent the information stored about the photograph. These are the array of integers and the date the photograph was taken (stored as a String). The values in the array must be...
CSC 142 Music Player You will complete this project by implementing one class. Afterwards, your program will play music from a text file. Objectives Working with lists Background This project addresses playing music. A song consists of notes, each of which has a length (duration) and pitch. The pitch of a note is described with a letter ranging from A to G. 7 notes is not enough to play very interesting music, so there are multiple octaves; after we reach...