transliteration-decoder: implement proper HTML escaping and add new transliteration model

This commit is contained in:
2023-10-29 21:13:48 +02:00
parent ec22c72afb
commit 51307b5234
2 changed files with 61 additions and 3 deletions
+9 -3
View File
@@ -4,8 +4,14 @@ command_length = len(command)
def escaped_string(unescaped_string):
result_string = str(unescaped_string)
for i in ["<", ">"]:
result_string = result_string.replace(i, f"\\{i}")
escaping_rules = {
"<": "&lt;",
">": "&gt;",
'"': "&quot;"
}
for i in escaping_rules.items():
result_string = result_string.replace(i[0], i[1])
return result_string
@@ -31,7 +37,7 @@ if (command[0] in self.aliases) and (1 <= command_length <= 3):
f"{', '.join(list(models.keys()))}"
else:
for i in models[chosen_model]:
decoded_text = decoded_text.replace(i[0], i[1])
decoded_text = decoded_text.replace(i[0].lower(), i[1].lower())
decoded_text = decoded_text.replace(i[0].capitalize(), i[1].capitalize())
decoded_text = decoded_text.replace(i[0].upper(), i[1].upper())