Transform any text into a patent application

Figure 2 From Scheerbart's Perpetual Motion Machine

Figure 2 From Paul Scheerbart’s Perpetual Motion Machine

[Hello everyone! Thanks for taking a look at my blog! If you want updates on this project or other things I’m working on, just follow me on twitter]

I wrote a program that transforms literary and philosophical texts into patent applications. In short, it reframes texts as inventions or machines. You can view the code on github.

I was partially inspired by Paul Scheerbart’s Perpetual Motion Machine, a sort of technical/literary diary in which Scheerbart documents and reflects on various failed attempts to create a perpetual motion machine. Scheerbart frequently refers to his machines as “stories” – I wanted to reverse the concept and transform stories into machines.

In this post I’ll provide some details about how I wrote the program, and describe some of the tools that I used.

First, here’s some sample output, listed by invention title and source text:

The program operates in four parts. First it generates a title for the invention, then an abstract, then a list of illustrations, and finally a more detailed description of the “embodiments” of the invention.

In general, my methodology is to find common grammatical structures in patent applications, and then extract sentences containing similar grammatical structures from my input texts. To do this, I make heavy use of the Pattern library, which, among many other wonderful features, allows you to perform regular-expression-like searches using parts of speech. For example, here’s how you can use pattern to to search through a text for all instances of an adjective followed by a plural noun:

Title Generation

There are a number of grammatical patterns that I noticed in patent application titles – one that stuck out to me is “[NOUN] (and [NOUN]) for [GERUND] [NOUN PHRASE]”. For example:

To create my invention titles, I simply search through the source text for “VBG * JJ? NP”, which translates to “a gerund, followed by anything, followed by an optional adjective, followed by a noun phrase.” The program selects an arbitrary title from all the options it finds, and then prefixes the title with a random combination of “system”, “method”, “apparatus”, and “device”. Occasionally it’ll add “web-based” into the mix as well. Here are a few of the many possible titles generated from the Communist Manifesto:

  • a web-based method and device for haunting Europe
  • an apparatus and device for rounding of the Cape
  • an apparatus and system for surpassing Egyptian pyramids
  • a web-based method and device for revolutionising the instruments
  • a system and device for clearing of whole continents
  • a web-based apparatus and method for paving the way
  • a system and apparatus for diminishing the means
  • an apparatus and system for fighting the bourgeoisie
  • a method and device for depicting the most general phases
  • a method and device for begetting a new supply
  • a method and apparatus for appropriating material products
  • a device and system for appropriating intellectual products
  • a system and device for springing from your present mode
  • a method and apparatus for having the wives
  • a web-based apparatus and method for desiring to abolish countries and nationality
  • a system and method for fluctuating between proletariat and bourgeoisie
  • a system and method for redressing social grievances

Generating an “Abstract”

Typically a patent application will have an abstract that describes in brief what the invention is comprised of. To generate my abstracts, I follow a similar method to the title generation, searching through my source text for instances of adjectives followed by singular or plural nouns. However, in this case I make a small but significant change. I restrict the possible nouns to those that fit into the category of “artifacts”. For example, here’s the abstract that gets generated from Heidegger’s essay on technology:

The devices comprises a wooden bridge, a technical apparatus, a high-frequency apparatus, a whole structure, a human handiwork, a mere handiwork, an autonomous tool, a hydroelectric plant, an actual chalice, an old windmill, a sacrificial chalice.

In order to do this, I wrote a function that searches first for grammatical patterns, and then filters that output based on hypernyms. A hypernym is a word that fits into a level of categorical abstraction up from another given word. So, a hypernym for “car” is “machine”, a hypernym for “pigeon” is “bird”. We can consider words sharing hypernyms as belonging to the same abstract category. This in itself is a fun tool to play with. For example, I can enter the following into my my program:

And I get a list of all the adjectives followed by nouns that fit into the “organism” category in Kafka’s The Metamorphosis:

  • old man
  • own mother
  • timorous visitor
  • observant sister
  • tired man
  • junior salesman
  • expressive violinist
  • middle gentleman
  • good man
  • unfortunate son
  • old maid
  • elderly widow
  • horrible vermin
  • elderly mother
  • chief clerk
  • wild man
  • fall victim
  • sensible person
  • lazy son
  • much mother
  • commercial traveller
  • young lady

Fun!

Illustrations

The next part of the program generates a list of “illustrations”. This time I search for phrases that fit into a grammatical structure that looks like “DT JJ NP IN * NN”, or, “determiner followed by adjective followed by noun phrase followed by a conjunction followed by anything, followed by a singular noun“. I attach these phrases to other randomly selected phrases commonly found in descriptions of patent illustrations. These “illustrations” come from Gargantua and Pantagruel by Rabelais:

  • Figure N illustrates the great puffguts of the counsellor.
  • Figure N is a schematic drawing of the first book of this translation.
  • Figure N is a perspective view of the old women in rut and heat.
  • Figure N is an isometric view of the middle finger of his right hand.
  • Figure N schematically illustrates a little peach-coloured bonnet with a great capon.
  • Figure N is a block diagram of the inundation of the urinal deluge.
  • Figure N is a cross section of the perfect image of my body.

I debated attaching actual illustrations to these descriptions, and even wrote a script to scrape Bing images for various patent illustrations, but in the end I decided the texts alone were better. I might explore the idea of programmatically creating illustrations in the future.

Detailed Description

The last part of my program creates a more detailed description of the invention. It does this by searching for “VB|VBD|VBZ|VBG * NN IN * NN”, or “any verb, followed by anything, followed by a noun, followed by a conjunction, followed by anything, followed by a noun.” I attach these, as in the illustrations section, to commonly found phrases in patent descriptions like “the present invention”, and “according to preferred embodiment”. Here are some excerpted results, from the Communist Manifesto:

The present invention is itself the product of a long course. The present invention finds its fitting complement in the most slothful indolence. The present invention creates a world after its own image. The present invention endangers the existence of bourgeois property. The present invention becomes an appendage of the machine.

According to another embodiment, the device layers the foundation for the sway. The device abolishes the right of personally acquired property. The device is the groundwork of all personal freedom.

According to another embodiment, the device is the miserable character of this appropriation. The device is the non-existence of any property. According to a preferred embodiment, the device deprives no man of power.

In accordance with an alternative specific embodiment, the present invention finds its complement in practical absence. The invention alters the character of intervention.

According to another embodiment, the device keeps even pace with dissolution. The invention is the most radical rupture with traditional property. The present invention is the condition for free development. The present invention comprehends the march of modern history.

According to another embodiment, the device is the necessary offspring of its own form. The present invention conceals the reactionary character of criticism. The present invention is the expression of the struggle.

According to a preferred embodiment, the invention expresses the struggle of one class. The invention presupposed the existence of modern bourgeois society. The invention improves the condition of every member.

Closing Thoughts

Soon I’ll create a little web service that runs the script on any user input. For the moment though you can download the code on github. The code base includes a number of (possibly) useful tools:

  • “machine.py” generates patents
  • “search.py” searches texts for parts of speech and hypernym combinations (among other things)
  • “get_illustrations.py” scrapes Bing for patent illustrations
  • “scraper.py” downloads the full text of patent applications based on keywords

BY THE WAY, if you ever want to kill a few hours, just search google patents for the dirtiest words you can come up with. You will not be disappointed.

A method and device for comprehending theoretically the historical movement.

A method and device for comprehending theoretically the historical movement.

ABSTRACT

A method and device for comprehending theoretically the historical movement. The device comprises a sentimental veil, a mere instrument, a whole surface, a modern working condition, an essential product, a poor stock-in-trade, heavy artillery, a present system, a feudal system, a great factory, a collective product, a last resort, a transcendental robe, a bribed tool.

BRIEF DESCRIPTION OF THE DRAWINGS

Figure 1 is an isometric view of the progressive historical development of the proletariat

Figure 3 schematically illustrates a certain stage in the development

Figure 5 is an isometric view of the whole superincumbent strata of official society

Figure 7 is an isometric view of the undeveloped state of class

Figure 8 is a perspective view of the first conditions for emancipation

Figure 9 is a cross section of the bourgeois sense

Figure 10 schematically illustrates the French criticism of the bourgeois State

Figure 11 is a block diagram of an independent section of modern society

Figure 12 schematically illustrates the disastrous effects of machinery and division

Figure 13 schematically illustrates a vast association of the whole nation

Figure 14 is a cross section of the misty realm of philosophical fantasy

Figure 15 is a perspective view of an agrarian revolution as the prime condition

Figure 18 is a schematic drawing of The essential condition for the existence

Figure 19 illustrates the first instinctive yearnings of that class

Figure 20 schematically illustrates the miraculous effects of their social science

Figure 21 is a cross section of The bourgeois clap-trap about the family

Figure 22 is a schematic drawing of the social character of the property

Figure 23 is a schematic drawing of all coercive measures against the working class

Figure 24 illustrates the hallowed co-relation of parent and child

Figure 25 is a perspective view of the ultimate general
results of the proletarian movement

Figure 26 is a block diagram of a supplementary part of bourgeois society

Figure 27 is a schematic drawing of the absolute monarchy as a counterpoise

Figure 29 illustrates the vanished status of the workman

Figure 30 schematically illustrates the great factory of the industrial capitalist

Figure 31 is a perspective view of these first movements of the proletariat

Figure 32 is a cross section of the little workshop of the patriarchal master

Figure 33 is a schematic drawing of the German philosophers of the eighteenth century

Figure 34 schematically illustrates the historical movement as a whole

Figure 35 is an isometric view of the practical absence of the family

Figure 36 illustrates the continued existence of bourgeois society

Figure 37 is an isometric view of the scattered state of the population

Figure 38 is a perspective view of a considerable part of the population

Figure 39 is a schematic drawing of the gradual , spontaneous class-organisation of the proletariat

Figure 40 is a perspective view of The individual members of this class

Figure 41 schematically illustrates the front the common interests of the entire proletariat

Figure 42 is a schematic drawing of the miserable character of this appropriation

Figure 43 illustrates a bribed tool of reactionary intrigue

Figure 44 schematically illustrates the whole surface of the globe

Figure 45 illustrates An oppressed class under the sway

Figure 46 illustrates the motley feudal ties that bound man

Figure 47 illustrates The immediate aim of the Communist

Figure 48 illustrates the feudal organisation of agriculture and manufacturing

Figure 49 is a perspective view of the great mass of the proletariat

Figure 50 is a diagrammatical view of The productive forces at the disposal

Figure 51 schematically illustrates the hostile antagonism between bourgeoisie and proletariat

Figure 52 schematically illustrates the icy water of egotistical calculation

Figure 53 illustrates the economic conditions for its emancipation

Figure 55 is a diagrammatical view of a national bank with State capital

Figure 56 is a perspective view of the exact contrary of its real character

Figure 57 illustrates all political action on the part

Figure 59 is a perspective view of the old cries of the restoration

Figure 60 illustrates the momentary interests of the working class

Figure 61 is an isometric view of a fantastic conception of its own position

Figure 62 is a schematic drawing of the revolutionary element in the tottering feudal society

Figure 63 illustrates the working-class parties of every country

Figure 64 is an isometric view of the reactionary character of their criticism

Figure 65 is an isometric view of the bombastic representative of the petty-bourgeois

Figure 66 is a schematic drawing of The first direct attempts of the proletariat

Figure 67 is a schematic drawing of the economical and political sway of the bourgeois class

Figure 68 is a perspective view of any distinctive social validity for the working class

Figure 69 is a perspective view of the Communistic abolition of buying and selling

Figure 70 is a block diagram of the first step in the revolution

Figure 71 is a diagrammatical view of these philosophical phrases at the back

Figure 72 is a perspective view of no other conclusion than that the lot

Figure 73 is an isometric view of the classical works of ancient heathendom

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

The present invention is itself the product of a long course. In accordance with an alternative specific embodiment, the present invention finds its fitting complement in the most slothful indolence. The present invention creates a world after its own image (comprising of an iconic mental representation) . The present invention endangers the existence of bourgeois property. The present invention becomes an appendage of the machine.

According to another embodiment, the device layers the foundation for the sway. The device abolishes the right of personally acquired property. The present invention is the groundwork of all personal freedom.

According to another embodiment, the device is the miserable character of this appropriation. The device is the non-existence of any property. According to a preferred embodiment, the invention deprives no man of power.

In accordance with an alternative specific embodiment, the present invention finds its complement in practical absence. The invention alters the character of intervention.

According to another embodiment, the device keeps even pace with dissolution. The invention is the most radical rupture with traditional property. The present invention is the condition for free development. The present invention comprehends the march of modern history.

According to another embodiment, the device is the necessary offspring (comprising of the immediate descendants of a person) of their own form. The present invention conceals the reactionary character of criticism.

According to a preferred embodiment, the invention is the head of this school. The present invention is the expression of the struggle.

According to a preferred embodiment, the invention expresses the struggle (comprising of an energetic attempt to achieve something) of one class. The invention presupposed the existence of modern bourgeois society. The invention improves the condition of every member.

The present invention is itself the product of a long course. In accordance with an alternative specific embodiment, the present invention finds its fitting complement in the most slothful indolence. The present invention creates a world after its own image (comprising of an iconic mental representation) . The present invention endangers the existence of bourgeois property. The present invention becomes an appendage of the machine.

According to another embodiment, the device layers the foundation for the sway. The device abolishes the right of personally acquired property. The present invention is the groundwork of all personal freedom.

According to another embodiment, the device is the miserable character of this appropriation. The device is the non-existence of any property. According to a preferred embodiment, the invention deprives no man of power.

In accordance with an alternative specific embodiment, the present invention finds its complement in practical absence. The invention alters the character of intervention.

According to another embodiment, the device keeps even pace with dissolution. The invention is the most radical rupture with traditional property. The present invention is the condition for free development. The present invention comprehends the march of modern history.

According to another embodiment, the device is the necessary offspring (comprising of the immediate descendants of a person) of their own form. The present invention conceals the reactionary character of criticism.

According to a preferred embodiment, the invention is the head of this school. The present invention is the expression of the struggle.

According to a preferred embodiment, the invention expresses the struggle (comprising of an energetic attempt to achieve something) of one class. The invention presupposed the existence of modern bourgeois society. The invention improves the condition of every member.

Ayn Random Twitter Bot

Caitlin Weaver and I made a twitter bot called AynRandom.

The bot tweets Randian phrases like “_____ is a parasite” with the blank filled in the nouns and noun phrases pulled from literary texts (right now, just Kafka’s “The Hunger Artist”).

We set up our python script on Dreamhost, and have a cron job posting to twitter every 30 minutes. To get things working on Dreamhost, we have the cron job call a simple shell script that activates a virtualenv environment. We’re using the twython library to post to twitter, and TextBlob to extract nouns and noun phrases for the tweets.

You can see our parasitical, moocher code on github.

Turn Any Literary Text Into A Legally Binding Contract

I created a python program the transforms literary texts into legal contracts. The script, which you can view on github, uses pattern-en and nltk.

Here’s a sample contract that uses Hemingway’s “The End of Something” as the source:

================
*** CONTRACT ***
================

_____________________________, henceforth known as “The Artist,” agrees to the following:

SECTION 1
The Artist will be a lumbering town. The Artist, a town. The Artist and The Artist agree to row along the shore. The Artist, rowing, will look at the white stone in the green trees. The Artist will say nothing.

SECTION 2
The Artist agrees to cut across the bay. The Artist agrees to be intent on the rod all the time they troll, even when The Artist agrees to talk. The Artist is obliged to love to fish. The Artist agrees to love to fish with The Artist.

SECTION 3
Within 30 days The Artist will pull hard on one oar so the boat will turn and the bait spinning far behind would pass where the trout will be feeding. The Artist hereby agrees to row the boat around to troll past both the feeding fish, then head it for the point. The Artist shall not reel in until the boat touch the shore.

SECTION 4
The Artist shall lift out a pail of live perch. The Artist will catch three of them with his hands and cut their heads off and skin them while The Artist chased with her hands in the bucket, finally catch a perch, cut its head off and skins it. The Artist agrees to look at her fish. The Artist must row the boat out over the channel-bank, holding the line in her teeth, and looking toward The Artist, who will stand on the shore holding the rod and letting the line run out from the reel. The Artist is required to come in with the boat and run the second line out the same way.

SECTION 5
The Artist will set a heavy slab of driftwood across the butt of the rod to hold it solid and prop it up at an angle with a small slab. The Artist must reel in the slack line so the line runs taut out to where the bait rest on the sandy floor of the channel and set the click on the reel. The Artist will row up the point a little way so The Artist would not disturb the line. The Artist will pull hard on the oars and the boat will go way up the beach.

SECTION 6
Within 6 days The Artist is obliged to step out of the boat and The Artist agrees to pull the boat high up the beach. The Artist shall go to the boat and bring a blanket. The Artist will spread the blanket out between the fire and the lake. The Artist agrees to sit on the blanket with her back to the fire and wait for The Artist. The Artist must come over and sit down beside her on the blanket.

SECTION 7
In a timely fashion The Artist shall look across the bay to the hills that begin to sharpen against the sky. The Artist hereby agrees to know the moon will be coming up. The Artist will look at her.

SECTION 8
Within 6 days The Artist is obliged to sit there with her back toward him. The Artist will look at her back. The Artist will go on.

SECTION 9
The Artist will stand up. The Artist is obliged to sit there, his head in his hands. The Artist agrees to be afloat in the boat on the water with the moonlight on it.

SECTION 10
By no later than April 14th, The Artist is required to go back and lay down with his face in the blanket by the fire. The Artist hereby agrees to lay there for a long time. The Artist will lay there while The Artist hears The Artist come into the clearing, walking around through the woods. The Artist is obliged to feel The Artist coming up to the fire.

================

Date: ________________________

Name: ________________________

Signature: ________________________

And here’s how the code works:

  • replace all proper nouns, and “he”s and “she”s with the phrase “The Artist”
  • search for sentences that contain the phrase “The Artist” and a verb
  • replace the verb with a legalist imperative
  • chop off anything in each sentence before the words “The Artist”
  • split the text into numbered sections that are between 3 and 6 sentences long
  • add a legalistic header and footer