From 8a6954997002a8961ead1df5feb9a75856cca45f Mon Sep 17 00:00:00 2001 From: tebarius Date: Tue, 22 Jul 2025 19:24:14 +0200 Subject: [PATCH] update git.ignore and remorse-generate-function --- .gitignore | 2 ++ Mysteryhelfer.pyw | 47 +++++++++++++++++++++-------------------------- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index 8f21f1d..05280ae 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ /data-extended/ /Hilfsprogramme/ /.idea/ +/data/t9-de.dic +/data/morse-de.dic \ No newline at end of file diff --git a/Mysteryhelfer.pyw b/Mysteryhelfer.pyw index 0b3e93a..0f9c6e1 100644 --- a/Mysteryhelfer.pyw +++ b/Mysteryhelfer.pyw @@ -2355,7 +2355,7 @@ befinden. else: try: wbfile = open("./data/german.dic", "r", - encoding="iso-8859-15") # german.dic von https://sourceforge.net/projects/germandict/ + encoding="iso-8859-1") # german.dic von https://sourceforge.net/projects/germandict/ except FileNotFoundError: Ausgabe.insert(1.0, hilfetext + "\n") else: @@ -2396,7 +2396,7 @@ befinden. Ausgabe.insert(1.0, hilfetext + "\n") else: try: - wbfile = open("./data/german.dic", "r", encoding="iso-8859-15") + wbfile = open("./data/german.dic", "r", encoding="iso-8859-1") except FileNotFoundError: Ausgabe.insert(1.0, hilfetext + "\n") else: @@ -2524,7 +2524,7 @@ im Unterverzeichnis "data" befinden. else: try: wbfile = open("./data/morse-de.dic", "r", - encoding="iso-8859-15") # german.dic von https://sourceforge.net/projects/germandict/ + encoding="iso-8859-1") # german.dic von https://sourceforge.net/projects/germandict/ except FileNotFoundError: try: testfile = open("./data/german.dic", "r") @@ -2573,7 +2573,7 @@ def remorse_germandic(): ualphabet["...--.."] = "ß" eingabetext = Eingabe.get(1.0, END) eingabetext = eingabetext.rstrip() - wbfile = open("./data/german.dic", "r", encoding="iso-8859-15") + wbfile = open("./data/german.dic", "r", encoding="iso-8859-1") Ausgabe.insert(1.0, "\n") for zeile in wbfile: zeile = zeile.strip(" \t\n\r") @@ -2602,24 +2602,19 @@ 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() @@ -2703,7 +2698,7 @@ im Unterverzeichnis "data" befinden. Ausgabe.insert(1.0, hilfetext + "\n") else: try: - wbfile = open("./data/t9-de.dic", "r", encoding="iso-8859-15") + wbfile = open("./data/t9-de.dic", "r", encoding="iso-8859-1") except FileNotFoundError: try: testfile = open("./data/german.dic", "r") @@ -2748,7 +2743,7 @@ def t9_germandic(): '-': '1', ',': '1', '+': '0', ')': '1', '(': '1', 'SS': '7'} eingabetext = Eingabe.get(1.0, END) eingabetext = eingabetext.rstrip() - wbfile = open("./data/german.dic", "r", encoding="iso-8859-15") + wbfile = open("./data/german.dic", "r", encoding="iso-8859-1") Ausgabe.insert(1.0, "\n") for zeile in wbfile: zeile = zeile.strip(" \t\n\r") @@ -2773,8 +2768,8 @@ def t9_generate_t9de(): '0': '0', 'Ñ': '6', 'É': '3', 'È': '3', 'À': '2', 'Ü': '8', 'Ö': '6', 'Ä': '2', '@': '1', '?': '1', '=': '0', ':': '1', '/': '1', '.': '1', '-': '1', ',': '1', '+': '0', ')': '1', '(': '1', 'SS': '7'} - ofile = open("./data/t9-de.dic", "a", encoding="iso-8859-15") - file = open("./data/german.dic", "r", encoding="iso-8859-15") + ofile = open("./data/t9-de.dic", "a", encoding="iso-8859-1") + file = open("./data/german.dic", "r", encoding="iso-8859-1") for zeile in file: omsg = "" zeile = zeile.rstrip()