Web M&M
https://mam.matfyz.cz
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.1 KiB
34 lines
1.1 KiB
2 years ago
|
bez_diakritiky = ({}
|
||
|
# FIXME: funguje jen pro český a slovenský text, jinak jsou špatně
|
||
|
# transliterace. Potenciální řešení:
|
||
|
# https://stackoverflow.com/questions/517923/what-is-the-best-way-to-remove-accents-normalize-in-a-python-unicode-string
|
||
|
# (ale přidává to další závislosti…)
|
||
|
|
||
|
# Tisknutelné ASCII
|
||
|
| {chr(a): chr(a) for a in range(32, 126+1)}
|
||
|
|
||
|
# České, slovenské a blízké diakritiky a divnoznaky
|
||
|
| { x: 'a' for x in 'áÁäÄ'}
|
||
|
| { x: 'c' for x in 'čČ'}
|
||
|
| { x: 'd' for x in 'ďĎ'}
|
||
|
| { x: 'e' for x in 'éÉěĚëË'}
|
||
|
| { x: 'i' for x in 'íÍ'}
|
||
|
| { x: 'l' for x in 'ľĽĺĹ'}
|
||
|
| { x: 'n' for x in 'ňŇ'}
|
||
|
| { x: 'o' for x in 'óÓöÖôÔ'}
|
||
|
| { x: 'r' for x in 'řŘŕŔ'}
|
||
|
| { x: 's' for x in 'šŠßẞ'}
|
||
|
| { x: 't' for x in 'ťŤ'}
|
||
|
| { x: 'u' for x in 'úÚůŮ'}
|
||
|
| { x: 'y' for x in 'ýÝ'}
|
||
|
| { x: 'z' for x in 'žŽ'}
|
||
|
)
|
||
|
|
||
|
# Tabulka pro str.translate
|
||
|
class _bez_diakritiky_translate:
|
||
|
def __getitem__(self, it):
|
||
|
return ord(bez_diakritiky.get(chr(it), None))
|
||
|
bez_diakritiky_translate = _bez_diakritiky_translate()
|
||
|
|
||
|
# TODO: testy?
|