MorseCode | final project for CS50x | Frontend Framework library
kandi X-RAY | MorseCode Summary
kandi X-RAY | MorseCode Summary
This is the final project for CS50x 2020. This app converts Text to Morse Code in 3 different formats!
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of MorseCode
MorseCode Key Features
MorseCode Examples and Code Snippets
Community Discussions
Trending Discussions on MorseCode
QUESTION
I am implementing Morse code using C and ran into some fundamentals.
Basic idea is I have 2-dimensional character array for A through Z. The first element of each array is an alphabet followed by corresponding Morse code. Program will receive a character which will be parsed through entire array once the match is found I will spit out the Morse code. I am able to run this program using help of simple array manipulation but I an running into issue with compact array.
The array is defined as below,
...ANSWER
Answered 2021-Nov-12 at 16:30You can simplify your lookup table by using the LETTER you want to code as an INDEX into the array. For example (not tested, no "bullet proofing" or error checking, only works for capital letters A..Z):
QUESTION
So I am doing this challenge:
Question:
It's 1868 and you've just bought a telegraph key so you can transmit messages in Morse code directly to your friend using a personal telegraph line. We've given you a file morsecode.txt which translates from any character (except a space) to its code. When a message is written in Morse code, characters are separated by spaces, while actual spaces are written as slash (/) in coded messages.
I want to split the input string into individual characters and verify it with the code in the file.
my code:
...ANSWER
Answered 2021-Aug-23 at 03:58Assuming data
dictionary is getting updated when you read from the text file, you can do the following:
QUESTION
I code a program for encode and decode a morse code, this code is for decode a morse code.
i use 2 arduino board, 1st Arduino is for encode the text into morse and 2nd is for receiving the morse and decode into text.Connection of 2 arduino board is using IR sensors.
in 1st arduino board This ARDU INO is a input of my code,then convert like this .-|.-.|-..|..-| |..|-.|---|, in this | is a end of word. Then transmit this morse code
in 2nd Arduino board it receives .-|.-.|-..|..-| |..|-.|---|, but its Decode like this "ARDUU INOO ",it print the same word twice which is before the space
why this happen? please help me
#define SIZE 26
...ANSWER
Answered 2021-Aug-07 at 16:59The issue seems to be in your extracting logic, there is no accounting for the #
to break the words, then because convertIntoText
does not have a default return path, when the input character is NOT in the expected 26 characters the response from the function used in the sketch is actually the previous response from that function call (this is an error state)
First rule, make sure all logic paths in your functions return a value, either inject a known error value, or deliberately raise an error. In this case a non-alpha character is good enough:
QUESTION
I am trying to use a {get; private set;} for a MorseCode translator I am building right now. The MorseToText
Dictionary is supposed to be built from a TextToMorse
Dictionary I have already defined. For some reason my Dictionary is empty when I use it though.
ANSWER
Answered 2021-Aug-06 at 11:39You never call your setter, hence your dictionary is never filled with values. In order to call the setter, you would have to write e.g. MorseToText = new Dictionary()
or e.g. MorseToText = null
at your code somewhere. Note that the value you feed into your setter will be discarded. If you called the setter twice, your code would throw an exception, because your dictionary already contains the keys. This is very confusing and because of that I recommend to use a static constructor. Maybe you also want to use a readonly Dictionary to expose your your dictionary:
QUESTION
So I'm trying to translate morsecode signals to their String representation. Some forms of preprocessing yield one dimensional arrays of normalized floats from [0, 1] that serve as input to a C/RNN. Example:
This image is stretched along the y-axis for better visibility, but the inputs to the NN are 1d. I'm looking for a smart way to translate the contens of the image, in this example the correct translation would be "WPM = TEXT I". My current model uses keras' ctc loss as in this tutorial. It will however detect the letter "E" for every single timestep ("E" is the morse equivalent of "." or a small bar in the image), so I figure that the "stepsize" is too small. This is reinforced by another attempt that classifies every timestep above some threshold as "E" and everything else als [UNK]/blank.
I think the main problem is the vast difference in size between for example an "E" (one thin line) and other characters, for example "=", represented by the small lines, framed by two thick ones as seen in the middle (-...-). This should be less of a problem in voice recognition, because there you can make phonetic sense of time-segments as small as microseconds (like hearing an "i" sound in "thin" and "gym") which is not possible in this context.
Perhaps anyone comes up with a smart solution, either to this implementation, or maybe through a different representation of inputs or something along those lines.
...ANSWER
Answered 2021-Jul-27 at 08:26I have also used CTC-loss successfully for extracting textual information from traffic sign plates.
Intuitively, unless you have many examples so that the CNN(encoder) can extract and actually learn that different sizes can actually point to the same letter, you will not be able to successfully learn this.
Indeed, the theoretical foundation for CTC does imply that the loss function is able to learn different sizes but in your particular case, a (thicker) line can easily also be classified as the same previous letter (thinner) one.
One possible attempt I would employ would be to reduce the length of the timesteps/max length of the words you are processing. Intuitively, this would (provided we keep the same width of the image) enforce a greater classification frame for the RNN. In your particular case this could potentially proved to be a helpful approach since you are interested in your networks capacity to interpret a broader region (not like CAPTCHA example in the tutorial).
So in the image below, the width of the bin would be wider, therefore allowing for a better grasp (the width of the pink rectangles would be bigger).
Another important aspect to consider is the dimensionality of the dataset. Ensure that you use augmentation and you have enough samples for training. What I have also remarked at CTC is that, for a successful result you also need a variety of text to be analyzed (not only the sample number but the text within the sample). Here, the amount of data plays an even greater role; it is easier for a network to distinguish between A and X but much harder to differentiate between thicker and thinner lines.
Image source: https://towardsdatascience.com/intuitively-understanding-connectionist-temporal-classification-3797e43a86c
QUESTION
So I wanted to make a state machine, that gets an input letter from the user and outputs the morsecode using a LED. I used a switch, but for some reason it doesn't want to work. It only worked for letter a, when i added another letter it stop working.
I used 3 functions (dot, line and pause) and combined them for the blinking of the LED. We are not allowed to use the "delay()" in our school so i made a timer.
...ANSWER
Answered 2021-Jun-13 at 14:03A lot could be said about this code. I really don't understand why you're doing things quite the way you are. But, if I go for the smallest change that would make your code work, it's as follows.
You have this sort of pattern repeated in your dot
, line
, pause
:
QUESTION
I am writing encode and decode functions for morse code. The encode function is working, but the decode function is giving the same output multiple times. Can someone see how i can fix the for loop to only print once. Btw it is printing backwards because I have it printing like that
sample input for decode function
...ANSWER
Answered 2021-Apr-13 at 01:47What about simply this?
QUESTION
data = {} #open dictionary
data.update({" " : "/"})
with open("morsecode.txt", "r") as f: #read file
for line in f: #read each line
key, value = line.split() #split key and value
data[key] = value #define key and value
#print(data) # test if dictionary work
msg = input("Message: ").upper() # reads user input
for letter in msg: #for every letter in the message
print(data[letter],end =" ") #output
...ANSWER
Answered 2021-Mar-03 at 18:56Try list comprehension and join the resulting list, e.g.:
QUESTION
When I get my decoder to run I can translate a word from Morse to normal but if I use more than one word it doesn't separate the words, how do I separate the words? Here is my code:
...ANSWER
Answered 2021-Jan-25 at 15:52Your example made it not possible. You are not giving any other separator than a space
in the input and so you are not able to divide words in any way.
Your solution is to give your input a word separator (for example
(double space), then split with .split(" ")
and loop tru words).
Other solution might be nltk
library, which might have some special functions for that - but here I'm just guessing.
QUESTION
I have created an English to Morse Code translator that requires a space between each Morse Code letter. In order to do this I added an extra space after every letter in the dictionary that can be seen below. However, this means at the end of the sentence there is an extra space (" "). Is there any way to remove this space?
I have attempted to use the str.slice function and it removes the whole morse code version of the last letter.
...ANSWER
Answered 2021-Jan-10 at 22:20That's a bad practice to include spaces for values that have nothing to do with the spacing; morse code characters do not have spaces.
I recommend using String.prototype.split()
on whatever english sentence you have, eg:
englishSentence.split().map(englishChar => morseCodeChar[englishChar]).join(' ');
You might have to use .toLowerCase()
or .toUpperCase()
or .filter()
bad characters from the english sentence.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install MorseCode
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page