schwurbler package

Submodules

schwurbler.schwurbler module

Little module offering functions to destroy text by repeated Google translations.

schwurbler.schwurbler.path_schwurbel(path, text)[source]

Feeds the given text through the given path of languages. The resulting translation is returned.

Parameters:
  • path (list) – List of languages to translate through.
  • text (str) – The text to translate.
Returns:

The resulting translated text as a string.

Examples

Translate “My hovercraft is full of eels.” from English to Japanese and back to English:

path = 'en,ja,en'
text = 'My hovercraft is full of eels.'
translated = path_schwurbel(path, text)
schwurbler.schwurbler.set_ratio_schwurbel(text, lang, langs='gu, gd, ga, gl, lb, la, lo, tr, lv, lt, th, tg, te, fil, haw, yi, ceb, yo, de, da, el, eo, en, eu, et, es, ru, zh-cn, ro, be, bg, uk, bn, jw, bs, ja, xh, co, ca, cy, cs, ps, pt, zh-tw, tl, pa, vi, pl, hy, hr, ht, hu, hmn, hi, ha, he, mg, uz, ml, mn, mi, mk, ur, mt, ms, mr, ta, my, af, sw, is, am, it, iw, sv, ar, su, zu, az, id, ig, nl, no, ne, ny, fr, ku, fy, fa, fi, ka, kk, sr, sq, ko, kn, km, st, sk, si, so, sn, sm, sl, ky, sd', target_ratio=50)[source]

Translates the given text through random languages until it only resembles the original text by the given ratio. The comparison metric used is a token set ratio.

Parameters:
  • text (str) – The text to schwurbel.
  • lang (str) – The language the text is in.
  • langs (str) – Comma-separated list of available languages to chose from.
  • target_ratio (int) – The target ratio to achieve before returning.
Returns:

The text re-translated to the given target ratio.

Raises:

ValueError – If the given languages are invalid.

schwurbler.schwurbler.validate_path(path)[source]

Takes a comma-separated list of languages and validates that each language is contained in googletrans.LANGUAGES

Parameters:path (str) – Comma-separated list of languages as a string.
Returns:The validated list of each language as a list.
Raises:ValueError – If the path string contains invalid languages.

Examples

Validate a translation from English, to Japanese, to English:

path = validate_path('en,ja,en')

Module contents

Main Schwurbler module.