tonybaldwin | blog

non compos mentis

Thou unmuzzled, malmsey-nosed scullian! (randomness in php)

with 6 comments

Some time ago, I wrote fo0l and Shakes, being random Shakespearean insult generators in python, fo0l being a basic script, and Shakes being the same, dressed up with a tkinter gui.

Today, I translated fo0l to php, creating a webinterface for this lovely linguistic tool.

Try it out HERE, if thou hast the heart, thou frothy, shard-borne haggard!

What did I do?
Let’s look at fo0l, first:

# Shakespearean insult generator

from random import randint

a = ("artless", "bawdy", "beslubbering", "bootless", "churlish", "cockered", "clouted", "craven", "currish", "dankish", "dissembling", "droning", "errant", "fawning", "fobbing", "froward", "frothy", "gleeking", "goatish", "gorbellied", "impertinent", "infectious", "jarring", "loggerheaded", "lumpish", "mammering", "mangled", "mewling", "paunchy", "pribbling", "puking", "puny", "qualling", "rank", "reeky", "roguish", "ruttish", "saucy", "spleeny", "spongy", "surly", "tottering", "unmuzzled", "vain", "venomed", "villainous", "warped", "wayward", "weedy", "yeasty", "cullionly", "fusty", "caluminous", "wimpled", "burly-boned", "misbegotten", "odiferous", "poisonous", "fishified", "Wart-necked") # 60 items

a1 = randint(0,59)
a2 = a[a1]

b = ("base-court", "bat-fowling", "beef-witted", "beetle-headed", "boil-brained", "clapper-clawed", "clay-brained", "common-kissing", "crook-pated", "dismal-dreaming", "dizzy-eyed", "doghearted", "dread-bolted", "earth-vexing", "elf-skinned", "fat-kidneyed", "fen-sucked", "flap-mouthed", "fly-bitten", "folly-fallen", "fool-born", "full-gorged", "guts-griping", "half-faced", "hasty-witted", "hedge-born", "hell-hated", "idle", "headed", "ill-breeding", "ill-nurtured", "knotty-pated", "milk-livered", "motley-minded", "onion-eyed", "plume-plucked", "pottle-deep", "pox-marked", "reeling-ripe", "rough-hewn", "rude-growing", "rump-fed", "shard-borne", "sheep-biting", "spur-galled", "swag-bellied", "tardy-gaited", "tickle-brained", "toad", "spotted", "unchin-snouted", "weather-bitten", " whoreson", "malmsey-nosed", "rampallian", "lily", "livered", "scurvy-valiant", "brazen-faced", "unwash'd", "bunch-back'd", "leaden-footed", "muddy-mettled", "pigeon-liver'd", "scale-sided") # 62 items

b1 = randint(0,61)
b2 = b[b1]

c = ("apple-john", "baggage", "barnacle", "bladder", "boar-pig", "bugbear", "bum-bailey", "canker-blossom", "clack-dish", "clotpole", "coxcomb", "codpiece", "death-token", "dewberry", "flap-dragon", "flax-wench", "flirt-gill", "foot-licker", "fustilarian", "giglet", "gudgeon", "haggard", "harpy", "hedge-pig", "horn-beast", "hugger-mugger", "joithead", "lewdster", "lout", "maggot-pie", "malt-worm", "mammet", "measle", "minnow", "miscreant", "moldwarp", "mumble-news", "nut-hook", "pigeon-egg", "pignut", "puttock", "pumpion", "ratsbane", "scut", "skainsmate", "strumpet", "varlot", "vassal", "whey-face", "wagtail", "knave", "blind-worm", "popinjay", "scullian", "jolt-head", " malcontent", "devil-monk", "toad", "rascal", "Basket-Cockle") # 60 items

c1 = randint(0,59)
c2 = c[c1]

print("Thou " + a2 + ", " + b2 + " " + c2 + "!")

Now, how did I translate that to php?




Written by tonybaldwin

May 17, 2011 at 6:44 pm

6 Responses

Subscribe to comments with RSS.

  1. I made it into a wordpress plugin, too.

    Look down at the bottom of the footer of this blog.


    Download the plugin here:


    May 18, 2011 at 1:48 pm

  2. Man, I love your scripts! I'm a translator too, and a Debian user. Not too much into coding and hacking (not more than required for everyday mundane use).

    For a quite a long time I was wondering about one thing, and I'm not that capable with scripting. Maybe you could help me or share several ideas on this little thing. Sometimes I get a whole "tree" of files with very descriptive filenames which need to be translated (content of the files, of course, but filenames too). Of course, that can be done one by one, but it's not as handy as doing it in a text editor, and all this work doesn't get into TM. So my idea was to collect all the filenames in a given directory recursively into a text file (so far I can do only that, not all the rest that I thought), save it into something like oldnames.txt, translate the oldnames.txt with OmegaT, put the translated file back but with a different name, like newnames.txt, and then have a script read filename#1 from oldfile.txt, rename it into filename#1 from newfile.txt and move to filename#2 in oldname.txt and so forth.

    Do you think you could hint me on how to do that? Or would it be of any interest to you to try to implement that?
    In any case, thanks again for what you've already shared, some real cool stuff here.


    July 19, 2011 at 3:32 pm

    • First, of course, I would list all the file names in a text file with
      ls -1 > sourcefilelist.txt
      or something.
      then translate that file, as you mentioned.

      Make sure the translated file has a different name, say "targetfilelist.txt" (or, for me, when I use OmegaT, it automatically appends the target language, so, if I had sourcefilelist.txt, the target file would be sourcefilelist_ENUS.txt, but for argument's sake, we'll just use targetfilelist.txt. NOTE, if your CAT is appending the language code, make sure you list the file accordingly!).
      Then, merge the two files with
      paste sourcefilelist.txt targetfilelist.txt > bothlists.txt

      That will give you one list with something like
      file-one.odt archivo-uno.odt
      file-two.odt archivo-dos.odt

      Then in the target file directory with that file, bothlists.txt, just do

      for i in $(awk '{ print $0}' bothlists.txt); do mv $i; done

      This should read each line, but appending mv, and running the command, thus doing

      mv file-one.odt archivo-uno.odt
      mv file-two.odt archivo-dos.odt

      effectively renaming each file.

      This is probably an ugly hack, and someone with stronger fu could do the whole freakin' job with some nifty oneline in perl, or something, but, it's all I've got, at the moment.


      September 6, 2011 at 7:49 pm

  3. Wait…I tried that…didn't quite work out…
    Hmmm…I'll be back.
    I got the lists working, but the little awk magick didn't quite behave as I'd hoped.
    It's sending
    mv file-one.odt mv archivo-uno.odt , it seems, rather than mv file-one.odt archivo-uno.odt


    September 6, 2011 at 7:56 pm

  4. Okay, got it.

    We need the following script:
    # read through the double list, rename files
    # from one side to the other side

    while read curline; do
    mv $curline
    done < "$INPUT_FILE"

    I called this "relist". Stick it in your path, or something.

    Then do

    relist bothlists.txt

    (or whatever you renamed the double list).

    It will go line by line through that list and rename the files.


    Now, still, likely somebody could find a way to do this with fewer steps, but let's reiterate:
    We list the source files
    ls -1 > sourcelist.txt
    we translate that list, then rename the translated list in the target directory
    mv sourcelist.txt > targetlist.txt
    now, merge the lists
    paste sourcelist.txt targetlist.txt > bothlist.txt
    then, we run our script on that list
    relist bothlist.txt

    Your target files will be renamed.

    I've gone through the process in greater detail on my wiki, here:


    September 6, 2011 at 8:23 pm

  5. Okay, at the above linked wiki page, ( ) another colleague assisted with a more efficient hack.

    Essentially, simply cd to the target directory in bash and do:
    paste ../source/sourcelist.txt sourcelist.txt | awk '{system("mv " $0)}'

    This can be saved in a script, of course. See the wiki page for more details.


    September 7, 2011 at 7:28 pm

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: