Skip to content

Instantly share code, notes, and snippets.

@pendingchaos
Last active October 7, 2015 14:01
Show Gist options
  • Save pendingchaos/3b30f1265d9589ff5424 to your computer and use it in GitHub Desktop.
Save pendingchaos/3b30f1265d9589ff5424 to your computer and use it in GitHub Desktop.
Translates a text a gazillion times then into English to produce awesomeness.

Example usage

cat <input file> | python2 gobbledygook.py > <output file>

Sample output

Rudolph, the Red-Nosed Reindeer
The nose is very strong.
If you do not see,
It should be great.

Right
Always smiling,
§
Available

Night Fog
Santa is coming
"Rudolph
Glad to hear

Then all
Shout

Other IL
Rudolf called nomojn.malriĉa
Play Ceirw.Nollag
He says:
The nose so bright,
In my sleigh tonight? "

Bank Hou
Broken

Red Deer Rudolph

Historical documents.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#This requires https://bitbucket.org/zhuoqiang/goslate/overview.
import goslate
import sys
import random
import time
import _codecs
gs = goslate.Goslate()
random.seed(time.time())
quality = random.randint(0, 10000) / 10000.0
iterations = random.randint(1, 10)
languages = ['el',
'eo',
'en',
'zh',
'af',
'sw',
'ca',
'it',
'iw',
'cy',
'ar',
'ga',
'cs',
'et',
'gl',
'id',
'es',
'ru',
'nl',
'pt',
'mt',
'tr',
'lt',
'lv',
'tl',
'th',
'vi',
'ro',
'is',
'pl',
'yi',
'be',
'fr',
'bg',
'uk',
'sl',
'hr',
'de',
'ht',
'da',
'fa',
'hi',
'fi',
'hu',
'ja',
'zh-TW',
'sq',
'no',
'ko',
'sv',
'mk',
'sk',
'zh-CN',
'ms',
'sr']
languages = languages[:int(len(languages) * (1.0 - quality))]
text = unicode(sys.stdin.read(), 'utf-8')
for i in xrange(iterations):
for lang in languages:
text = gs.translate(text, lang)
time.sleep(1.0)
sys.stdout.write(_codecs.encode(gs.translate(text, 'en'), 'utf-8'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment