#!/usr/bin/env python """ imkrozh.py - Converts from English to Imkrozh and vice versa Author: Sean B. Palmer, inamidst.com Imkrozh is actually a cipher of English, but one that is carefully chosen so that it still looks like an Indo European natural language of some kind. In fact, the first ever line of Imkrozh that I said to someone was deciphered by them, though subsequent lines proved much harder. It works on a principle of mapping voiced phonemes to unvoiced ones, and vice versa, though of course it would work better if English had a regular orthography. All of the vowels are rshifted once in the sequence "aeiou". This is mainly a toy "language", but it has the very interesting property of being a steganographic device too. It was partly inspired by a friend who occasionally conflates his voiced and unvoiced phonemes. Here's the previous paragraph in Imkrozh: Thoz oz neomry e duy "remkaeki", pad od hez thi fily omdilizdomk blubildy uv piomk e zdikemuklebhoc tifoci duu. Od wez beldry omzbolit py e vloimt whu uccezoumerry cumvrediz hoz fuocit emt amfuocit bhuminiz. """ import sys, fileinput from optparse import OptionParser class Bidict(dict): def __init__(self, *args, **kargs): super(Bidict, self).__init__(*args, **kargs) dict.update(self, dict((v, k) for k, v in self.iteritems())) def __setitem__(self, k, v): dict.__setitem__(self, k, v) dict.__setitem__(self, v, k) vowels = {'a': 'e', 'e': 'i', 'i': 'o', 'o': 'u', 'u': 'a'} rvowels = {'e': 'a', 'i': 'e', 'o': 'i', 'u': 'o', 'a': 'u'} phonetics = Bidict( {'th': 'th', 'g': 'k', 'p': 'b', 't': 'd', 'qu': 'kw', 'r': 'l', 's': 'z', 'ch': 'j', 'f': 'v', 'n': 'm'} ) def convert(text, english=True): result = '' text = text.lower() while text: double = text[:2] if phonetics.has_key(double): result += phonetics[double] text = text[2:] else: single = text[:1] if phonetics.has_key(single): result += phonetics[single] elif english and vowels.has_key(single): result += vowels[single] elif (not english) and rvowels.has_key(single): result += rvowels[single] else: result += single text = text[1:] return result def interactive(): while True: try: text = raw_input('Input: ') except (KeyboardInterrupt, EOFError): break print '>', convert(text) def main(argv=None): parser = OptionParser(usage='%prog [options] *') parser.add_option("-c", "--chars", dest="chars", default=False, help="pass the input on the command line") parser.add_option("-i", "--imkrozh", dest="imkrozh", action="store_true", default=False, help="convert from Imkrozh to English") options, args = parser.parse_args(argv) if options.chars and args: parser.error("Can't have both -c option and filenames.") english = (not options.imkrozh) if args: for line in fileinput.input(): sys.stdout.write(convert(line, english=english)) elif options.chars: print convert(options.chars, english=english) else: interactive() if __name__=="__main__": main()