#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import os
import getopt

greek = u'ΑΆΒΓΔΕΈΖΗΉΙΊΪΚΛΜΝΟΌΠΡΣΤΥΎΫΦΧΩΏαάβγδεέζηήιίϊΐκλμνοόπρσςτυύϋΰφχωώ;'
latin = u'AABGDEEZHHIIIKLMNOOPRSTYYYFXWWaabgdeezhhiiiiklmnooprsstuuuufxww?'

mapping = dict(zip(greek, latin))

def gr2gl(string, all_caps):
    result = []

    for c in string:
        double = True
        if c in (u'Θ', u'θ'):
            to_append = 'th'
        elif c in (u'Ξ', u'ξ'):
            to_append = 'ks'
        elif c in (u'Ψ', u'ψ'):
            to_append = 'ps'
        else:
            double = False
            to_append = mapping.get(c, c)

        if double and c == c.upper():
            if all_caps:
                to_append = to_append.capitalize()
            else:
                to_append = to_append.title()

        result.append(to_append)

    return u''.join(result)

caps = False
usage = '''Usage:
  %s [options] text

Options:
  -h, --help  Show this help message and exit
  -c, --caps  Consider the whole text consisting of capital letters
''' % os.path.basename(sys.argv[0])

try:
    opts, args = getopt.getopt(sys.argv[1:], 'ch', ('caps', 'help'))
except getopt.GetoptError:
    sys.exit(usage)

for option, value in opts:
    if option in ('-h', '--help'):
        print usage
        sys.exit()
    if option in ('-c', '--caps'):
        caps = True

if args:
    args = map(unicode, args, ('utf-8',) * len(args))
    args = u' '.join(args)
else:
    args = unicode(sys.stdin.read(), 'utf-8')

print gr2gl(args, caps)
