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
**/*.pyo
**/__pycache__
**/__pycache__
**/morse-de.dic
**/t9-de.dic

2
.gitignore vendored
View File

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