Can I access an English dictionary to scroll through nautical code matches? If not, can I copy and paste it from somewhere on multiple lines?
So I'm writing a program in python 2.7 that looks through all the words in the English language to see if the English version matches Morse code for an unknown Morse phrase. The reason I can't just interpret this is because there are no spaces between letters. This is a piece of code:
def morse_solver(nol,morse,words):
#nol is the number of letters to cut down search time,morse is the Morse phrase to decode, and words is a string (or can be a list) of all english words.
lista=_index(words)
#_index is a procedure that organizes the input in the following way:[nol,[]]
selection=lista[nol-1][1]
#selects the words with that nol to loop through
for word in selection:
if morse_encode(word)==morse:
print morse+"="+word
So my question is:
It's hard to find a list of all the words in English and copy it into a huge string. So, is there a way or some Python module to access all the words in the English dictionary just by typing a little?
If no such thing exists, how can I handle such a large string? Is there a place where I can copy paste (one line)? thanks in advance
+3
source to share
2 answers
What fun is Morse code if you can't hear it? Let me know if this doesn't work in Python 2.7:
from winsound import Beep
from time import sleep
dot = 150 # milliseconds
dash = 300
freq = 2500 #Hertz
delay = 0.05 #delay between beeps in seconds
def transmit(morseCode):
for key in morseCode:
if key == '.':
Beep(freq,dot)
elif key == '-':
Beep(freq,dash)
else:
pass #ignore (e.g. new lines)
sleep(delay)
example = '----. ----. -... --- - - .-.. . --- ..-. -... . . .-.'
#This last is the first line of
#99 Bottles of Beer in Morse Code
#from http://99-bottles-of-beer.net/language-morse-code-406.html
transmit(example)
+1
source to share