Created
March 9, 2018 12:45
-
-
Save tim6her/a4c19f9804a16a644429a406ed056865 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
from __future__ import absolute_import, print_function, division | |
from itertools import combinations_with_replacement | |
from pylatexenc.latex2text import LatexNodes2Text | |
encoder = LatexNodes2Text() | |
chars = ((r'\"{o} ', 'ö '), | |
(r'{\"o} ', 'ö '), | |
(r'\L ', 'Ł'), | |
(r'{\L} ', 'Ł '), | |
('u ', 'u ')) | |
def dot_or_F(tex, uni): | |
uni_tex = encoder.latex_to_text(tex) | |
if uni_tex.strip() == uni.strip(): | |
return ('.', uni_tex) | |
return ('F', uni_tex) | |
print('{code}:\t{tex}\t{uni_tex}'.format(tex='tex code'.ljust(19), | |
code=' ', uni_tex='encoded output')) | |
for cc in combinations_with_replacement(chars, 3): | |
ttex, uuni = list(zip(*cc)) | |
tex = ''.join(ttex) | |
uni = ''.join(uuni) | |
code, uni_tex = dot_or_F(tex, uni) | |
print('{code}:\t{tex}\t{uni_tex}'.format(tex=tex.ljust(19), | |
code=code, uni_tex=uni_tex)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment