updated generate-remorse-function

This commit is contained in:
2025-07-22 19:39:47 +02:00
parent f838acd724
commit 9fc0620e04
3 changed files with 18 additions and 21 deletions

View File

@@ -1,3 +1,5 @@
**/*.pyc **/*.pyc
**/*.pyo **/*.pyo
**/__pycache__ **/__pycache__
**/morse-de.dic
**/t9-de.dic

2
.gitignore vendored
View File

@@ -1,3 +1,5 @@
/app/__pycache__/ /app/__pycache__/
/venv/ /venv/
/.idea/ /.idea/
/app/data/morse-de.dic
/app/data/t9-de.dic

View File

@@ -2088,7 +2088,6 @@ def remorse_germandic():
Ausgabe.insert(1.0, ualphabet[eingabetext] + "\n") Ausgabe.insert(1.0, ualphabet[eingabetext] + "\n")
Ausgabe.insert(1.0, "der eingegebene Morsecode kann für folgendes stehen:\n", "bu") Ausgabe.insert(1.0, "der eingegebene Morsecode kann für folgendes stehen:\n", "bu")
def remorse_generate_morsede(): def remorse_generate_morsede():
alphabet = {'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.', 'G': '--.', alphabet = {'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.', 'G': '--.',
'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..', 'M': '--', 'N': '-.', 'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..', 'M': '--', 'N': '-.',
@@ -2100,27 +2099,21 @@ def remorse_generate_morsede():
'?': '..--..', '=': '-...-', ';': '-.-.-.', ':': '---...', '/': '-..-.', '?': '..--..', '=': '-...-', ';': '-.-.-.', ':': '---...', '/': '-..-.',
'.': '.-.-.-', '-': '-....-', ',': '--..--', '+': '.-.-.', ')': '-.--.-', '.': '.-.-.-', '-': '-....-', ',': '--..--', '+': '.-.-.', ')': '-.--.-',
'(': '-.--.', "'": '.----.', 'SS': '...--..'} '(': '-.--.', "'": '.----.', 'SS': '...--..'}
ofile = open("./data/morse-de.dic", "a", encoding="iso-8859-15") with open("./data/morse-de.dic", "w", encoding="iso-8859-1") as ofile:
ofile.write("-----,0\n.----,1\n..---,2\n...--,3\n....-,4\n.....,5\n-....,6\n--...,7\n---..,8\n----.,9\n") for symbol, morse in alphabet.items():
ofile.write(".-,A\n-...,B\n-.-.,C\n-..,D\n.,E\n..-.,F\n--.,G\n....,H\n..,I\n.---,J\n-.-,K\n.-..,L\n--,M\n") ofile.write(f"{morse},{symbol}\n")
ofile.write("-.,N\n---,O\n.--.,P\n--.-,Q\n.-.,R\n...,S\n-,T\n..-,U\n...-,V\n.--,W\n-..-,X\n-.--,Y\n--..,Z\n") with open("./data/german.dic", "r", encoding="iso-8859-1") as infile:
ofile.write("--.--,Ñ\n..-..,É\n.-..-,È\n.--.-,À\n..--,Ü\n---.,Ö\n.-.-,Ä\n..--.-,_\n.--.-.,@\n..--..,?\n-...-,=\n") for line in infile:
ofile.write("-.-.-.,;\n---...,:\n-..-.,/\n.-.-.-,.\n-....-,-\n.-.-.,+\n-.--.-,)\n-.--.,(\n.----.,'\n...--..,ß\n") word = line.strip()
file = open("./data/german.dic", "r", encoding="iso-8859-15") try:
for zeile in file: morse_word = ''.join(alphabet[char.upper()] for char in word)
omsg = "" ofile.write(f"{morse_word},{word}\n")
zeile = zeile.rstrip() except KeyError:
try: # Überspringe Wörter mit nicht-unterstützten Zeichen
for char in zeile: continue
omsg = omsg + alphabet[char.upper()] infile.close()
except TypeError:
continue
else:
ofile.write(omsg + "," + zeile + "\n")
file.close()
ofile.close() ofile.close()
def remorse_en(): def remorse_en():
hilfetext = """HILFE: [RE-Morse EN] hilfetext = """HILFE: [RE-Morse EN]
Es gibt ja so Leute, die finden es lustig einen Es gibt ja so Leute, die finden es lustig einen