Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@pfactum
Created November 2, 2016 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pfactum/9390abf7e5a25755ab44e878909f6d13 to your computer and use it in GitHub Desktop.
Save pfactum/9390abf7e5a25755ab44e878909f6d13 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import sys, re
latinization = []
prelatin = "абвгґдеєжзиіїйклмнопрстуфхцчшщьюяАБВГҐДЕЄЖЗИІЇЙКЛМНОПРСТУФХЦЧШЩЬЮЯ"
postlatin = "abvgğdeěžzyiïjklmnoprstufhcčšşʹŭăABVGĞDEĔŽZYIÏJKLMNOPRSTUFHCČŠŞʹŬĂ"
for index in range(len(prelatin)):
latinization.append([prelatin[index], postlatin[index]])
desoftinization = []
predesoft = "dtzsclnDTZSCLN"
postdesoft = "ḋṫżṡċŀṅḊṪŻṠĊĿṄ"
for index in range(len(predesoft)):
desoftinization.append([predesoft[index] + "ʹ", postdesoft[index]])
deapostrophization = []
predeapostroph = "ăŭěïĂŬĔÏ"
postdeapostroph = "ӓüëïÄÜËÏ"
for index in range(len(predeapostroph)):
deapostrophization.append(["'" + predeapostroph[index], postdeapostroph[index]])
deapostrophization.append(["’" + predeapostroph[index], postdeapostroph[index]])
postvowelization = []
vowels = "aouyieAOUYIEăŭěïĂŬĔÏ"
for i in range(len(vowels)):
for j in range(len(predeapostroph)):
postvowelization.append([vowels[i] + predeapostroph[j], vowels[i] + postdeapostroph[j]])
postspaceization = []
for index in range(len(predeapostroph)):
postspaceization.append([" " + predeapostroph[index], " " + postdeapostroph[index]])
poststarting = []
for index in range(len(predeapostroph)):
poststarting.append(["^" + predeapostroph[index], postdeapostroph[index]])
for line in sys.stdin:
for item in latinization:
line = line.replace(item[0], item[1])
for item in desoftinization:
line = line.replace(item[0], item[1])
for item in deapostrophization:
line = line.replace(item[0], item[1])
for item in postvowelization:
line = line.replace(item[0], item[1])
for item in postspaceization:
line = line.replace(item[0], item[1])
for item in poststarting:
line = re.sub(item[0], item[1], line)
print(line, end = "", flush = True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment