anagramm wortsuche remorse t9

This commit is contained in:
2025-07-23 23:40:25 +02:00
parent 8074b04ab7
commit a2ee24bf1d
3 changed files with 280 additions and 350 deletions

View File

@@ -178,4 +178,110 @@ def unkennify(text):
i = i + 1
if i < n_len:
decoded = decoded + text[i:]
return decoded
return decoded
def remorse_generate_morsede():
alphabet = {'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.', 'G': '--.',
'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..', 'M': '--', 'N': '-.',
'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.', 'S': '...', 'T': '-', 'U': '..-',
'V': '...-', 'W': '.--', 'X': '-..-', 'Y': '-.--', 'Z': '--..', '1': '.----',
'2': '..---', '3': '...--', '4': '....-', '5': '.....', '6': '-....', '7': '--...',
'8': '---..', '9': '----.', '0': '-----', 'Ñ': '--.--', 'É': '..-..', 'È': '.-..-',
'À': '.--.-', 'Ü': '..--', 'Ö': '---.', 'Ä': '.-.-', '_': '..--.-', '@': '.--.-.',
'?': '..--..', '=': '-...-', ';': '-.-.-.', ':': '---...', '/': '-..-.',
'.': '.-.-.-', '-': '-....-', ',': '--..--', '+': '.-.-.', ')': '-.--.-',
'(': '-.--.', "'": '.----.', 'SS': '...--..'}
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 t9_generate_t9de():
alphabet = {'A': '2', 'B': '2', 'C': '2', 'D': '3', 'E': '3', 'F': '3', 'G': '4',
'H': '4', 'I': '4', 'J': '5', 'K': '5', 'L': '5', 'M': '6', 'N': '6',
'O': '6', 'P': '7', 'Q': '7', 'R': '7', 'S': '7', 'T': '8', 'U': '8',
'V': '8', 'W': '9', 'X': '9', 'Y': '9', 'Z': '9', '1': '1', '2': '2',
'3': '3', '4': '4', '5': '5', '6': '6', '7': '7', '8': '8', '9': '9',
'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")
for zeile in file:
omsg = ""
zeile = zeile.rstrip()
try:
for char in zeile:
omsg = omsg + alphabet[char.upper()]
except KeyError:
continue
else:
ofile.write(omsg + "," + zeile + "\n")
file.close()
ofile.close()
def remorse_germandic(eingabetext):
alphabet = {'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.', 'G': '--.',
'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..', 'M': '--', 'N': '-.',
'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.', 'S': '...', 'T': '-', 'U': '..-',
'V': '...-', 'W': '.--', 'X': '-..-', 'Y': '-.--', 'Z': '--..', '1': '.----',
'2': '..---', '3': '...--', '4': '....-', '5': '.....', '6': '-....', '7': '--...',
'8': '---..', '9': '----.', '0': '-----', 'Ñ': '--.--', 'É': '..-..', 'È': '.-..-',
'À': '.--.-', 'Ü': '..--', 'Ö': '---.', 'Ä': '.-.-', '_': '..--.-', '@': '.--.-.',
'?': '..--..', '=': '-...-', ';': '-.-.-.', ':': '---...', '/': '-..-.',
'.': '.-.-.-', '-': '-....-', ',': '--..--', '+': '.-.-.', ')': '-.--.-',
'(': '-.--.', "'": '.----.', 'SS': '...--..'}
ualphabet = {v: k for k, v in alphabet.items()}
ualphabet["...--.."] = "ß"
eingabetext = eingabetext.rstrip()
wbfile = open("./data/german.dic", "r", encoding="iso-8859-15")
ausgabetext = "_der eingegebene Morsecode kann für folgendes stehen:_ \n"
if eingabetext in ualphabet:
ausgabetext += ualphabet[eingabetext] + " \n"
for zeile in wbfile:
zeile = zeile.strip(" \t\n\r")
mzeile = ""
try:
for char in zeile:
mzeile += alphabet[char.upper()]
except KeyError:
continue
if eingabetext == mzeile:
ausgabetext += zeile + " \n"
wbfile.close()
return ausgabetext
def t9_germandic(eingabetext):
alphabet = {'A': '2', 'B': '2', 'C': '2', 'D': '3', 'E': '3', 'F': '3', 'G': '4',
'H': '4', 'I': '4', 'J': '5', 'K': '5', 'L': '5', 'M': '6', 'N': '6',
'O': '6', 'P': '7', 'Q': '7', 'R': '7', 'S': '7', 'T': '8', 'U': '8',
'V': '8', 'W': '9', 'X': '9', 'Y': '9', 'Z': '9', '1': '1', '2': '2',
'3': '3', '4': '4', '5': '5', '6': '6', '7': '7', '8': '8', '9': '9',
'0': '0', 'Ñ': '6', 'É': '3', 'È': '3', 'À': '2', 'Ü': '8', 'Ö': '6',
'Ä': '2', '@': '1', '?': '1', '=': '0', ':': '1', '/': '1', '.': '1',
'-': '1', ',': '1', '+': '0', ')': '1', '(': '1', 'SS': '7'}
eingabetext = eingabetext.rstrip()
wbfile = open("./data/german.dic", "r", encoding="iso-8859-15")
ausgabetext = "_der eingegebene T9-Code kann für folgendes stehen:_ \n"
for zeile in wbfile:
zeile = zeile.strip(" \t\n\r")
mzeile = ""
try:
for char in zeile:
mzeile += alphabet[char.upper()]
except KeyError:
continue
if eingabetext == mzeile:
ausgabetext += zeile + " \n"
wbfile.close()
return ausgabetext