Dissociated clipboard

When I read Michael Bérubé’s analysis of a silly young right-winger’s article on feminism, my first thought was that he’d used some version of Dissociated Press to produce it. Then I thought maybe that was how the original article had been written. Either way, I had make a TextExpander snippet for generating that kind of nonsense on the fly.

I’d already written snippets for making nonsense paragraphs based on predefined texts: first Darwin’s Origin of Species and then Dolbear’s The Machinery of the Universe. Both snippets were Perl scripts that used Avi Finkel’s Games::Dissociated module. What I wanted now was a snippet that would produce nonsense based on whatever text was on the clipboard.

I won’t repeat my descriptions of how to get and install the module, how the script works, or how to turn it into a snippet—you can read the aforelinked posts for that. Here’s the script itself:

perl:
 1:  #!/usr/bin/perl
 2:  
 3:  use Games::Dissociate;
 4:  
 5:  # Get the corpus from the clipboard.
 6:  $corpus = `/usr/bin/pbpaste`;
 7:  
 8:  # Dissociate the corpus, using word pairs, and return 15-50 pairs.
 9:  $length = int(15 + rand(35));
10:  $dis = dissociate($corpus, -2, $length);
11:  
12:  # Capitalize the first word and end with a period.
13:  $dis =~ s/^(.)/\u\1/;
14:  $dis =~ s/[.);:?'", -]+$/./;
15:  
16:  print $dis;

I set the abbreviation to ;diss.

With Mr. Poulos’s dopey article on the clipboard, I generated this:

Public pressure. The court’s solution was to bend to the public reality that millions of women had altered what it meant to be straight but now isn’t, tells The New York Times Sunday Magazine exactly what establishment liberals don’t get to define my.

Being excoriated for voting against the Violence Against Women Act, for pushing transvaginal ultrasounds, and for that reason conservative folkways, prejudices, and ideals are once again on trial. Rick Santorum may be easing up on the upswing, but everyone else feels their civilization is doing worthless work unless they take the controversies.

A place liberals contemptuously deride as beneath human dignity when referenced in terms of the suffering of the left stops well short of the best places to look for a way out of the human race, but it is anathema to most conservatives of any political party, and for that very active moral claim. Today, the significant battle is over what women are for flow naturally from this wise and enduring consensus, but no faction of conservatives or liberals has.

Pretty damned close to the original.

More important, now I can create dissociated text from any corpus without having to edit the script.


4 Responses to “Dissociated clipboard”

  1. Gabe says:

    Why did you go with Perl instead of Python? Habit? Limitations of the Python module? Distaste for white-space? Why not Ruby?

  2. Gabe says:

    Sorry. I assume this is still the case:

    “I chose Avi Finkel’s Perl implementation, called Games::Dissociated, because it had the best documentation and would be the easiest to figure out.”

  3. Dr. Drang says:

    When trying to guess my motivations, laziness is a pretty good bet. In this case, by sticking with what I used before, I only had to change one line.

  4. Aristotle Pagaltzis says:

    I find computer-generated prose often has a haunting, eerily truthful quality… in this case “Everyone […] feels their civilization is doing worthless work unless they take the controversies.”