Created
March 30, 2011 09:16
-
-
Save ojii/894111 to your computer and use it in GitHub Desktop.
A script that translates any language into French!
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/python | |
# -*- coding: utf-8 -*- | |
import argparse | |
import random | |
mappings = { | |
'a': [u'à', u'â'], | |
'c': [u'ç'], | |
'e': [u'é', u'è', u'ê'], | |
} | |
def _frenchify_single(bit, i): | |
if bit not in mappings: | |
return bit | |
choices = [bit] | |
for x in range(i): | |
choices += mappings[bit] | |
return random.choice(choices) | |
def frenchify(value, i): | |
return ''.join([_frenchify_single(bit, i) for bit in value]) | |
def main(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument('-i', default=1, type=int) | |
parser.add_argument('data') | |
namespace = parser.parse_args() | |
print frenchify(namespace.data, namespace.i) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bâhm! Instànt Frènçh :)