S+7 through NLTK


One of the earliest Oulipian procedures is Jean Lescure’s S+7. While its status as a constraint is debatable (originally called a method, sometimes referred to as a procedure), it is one of the most cited and perhaps also least understood of the Oulipo’s long list of techniques.

To begin, S stands for “substantif” (noun), but can be theoretically replaced with any other part of speech. One of the founders of the Oulipo, François Le Lionnais, pointed out that S+7 is a more specific version of m±n, where m is a “meaningful” part of speech and n is any integer. Carrying out an S+7 or any of its variations should be a purely mechanical procedure. All an author needs are two very important pieces: a pre-written text and a dictionary. Then, the author identifies all the nouns and replaces them with the nouns that come seven entries later in a dictionary of their choosing. The result therefore depends upon the original text and the dictionary chosen, but not much else.


In the bench Governor created the help and the economist.
And the economist was without forum, and void; and day was upon the failure of the deep. And the Spring of Governor moved upon the failure of the weddings.
And Governor said, Let there be link: and there was link.

(generated on http://www.spoonbill.org/n+7/)

The interest of this particular S+7 and indeed most of the Oulipo’s best-loved examples is that the original text (Genesis from the Bible) is extremely recognizable. It isn’t the dictionary that led to the hilarity of the result, but rather that even with the noun substitutions, the original text is still very much audible, but with unexpected new words. While the choice of the dictionary could have created more specific substitutions, the Oulipo has not really done much experimenting with the dictionaries — they have used big ones and small ones (and in the case of one Queneau S+7, a culinary one).

Natural Language Processing

For my digital humanities project, I am making my own S+7 program using nltk with python. While my earlier programming efforts were difficult for a beginner, trying my hand at nltk makes me feel like I’ve made it to another level entirely. Going through their online textbook has been very helpful and has reinforced the programming knowledge I have already gained through working on this project. Also, Natural Language Processing has helped me better understand the early constraints of the Oulipo, greatly contributing to my chapter on algebra which includes analysis of the S+7 and its variations, as well as other methods that are based on simple substitutions, counting, or operations.

I am pleased to report that I am putting the final touches on this last program, which will allow the reader to generate a dictionary based on one author’s vocabulary (the one I am currently working with takes all the nouns from Edgar Allan Poe’s collected poetry) and substitute those nouns into a short excerpt from several other recognizable texts (Moby Dick, The Declaration of Independence, Genesis, A Tale of Two Cities, and The Raven).

Once I have worked out the kinks in my pluralizing function (if the original noun is plural, I need the substituted one to be plural as well), I will publish the code online in my Github repository as well as here on CORE. While I do not believe that this code is particularly useful, the process of creating it was invaluable to me as a scholar and a programmer. I now understand the Oulipo and their computer efforts much better, as well as their elementary procedures. Programming texts that seem gimmicky, but that are hardly ever “read” (such as the Cent mille milliards de poèmes) has forced me to design new ways to read them. I have also gained new insights into the digital humanities and how it can be used not to produce an online archive or digital editions of texts (though, I have created interactive, digital editions of certain texts or procedures), but rather to open eyes to the possibilities in such experimental fiction. Works written using new methods must be analyzed using new methods. In that sense, it was the intellectual process of carrying out this project and not the process itself that I will take with me.

Digital Oulipo: Graph Theory for Literary Analysis

Raymond Queneau published Un conte à votre façon in 1967 in the midst of the Russian formalism excitement spurred by the translations of Vladimir Propp and his contemporaries. Propp’s premise is that all folktales can be broken into their simplest 31 narrative functions following an initial situation. À votre façon refers to a potential reader, who can compose it as he/she sees fit given a set of binary choices provided by Queneau. This “tree structure” comes from the mathematical field of graph theory that was being developed at that time by fellow Oulipian, Claude Berge. Queneau’s tale can, incidentally, be represented as a graph.

A graphical representation of the text designed by Queneau and published in a collected volume of the Oulipo

Queneau’s story initially gives this reader a choice between the story of three little peas, three big skinny beanpoles, or three average mediocre bushes. The following choices are all binary, and mostly stark oppositions. This is also a feature of algorithms, in the sense that binary choices must provide mutually exclusive alternatives. If not, the system would be contradictory. For instance, either the reader chooses to read the tale of the three peas or he does not. Should the reader prefer not to read this first option, (s)he will find that the two alternatives offer rather meager results. Refusing all three terminates the program almost immediately.

As with these preliminary choices, most nodes in Queneau’s short tale are superficial or contradictory, giving the reader only an illusion of choice. While the story and its various itineraries can be visualized as a flow chart, the story leaves very little freedom to the reader. The genius of the text lies in the simultaneous display of all possible options, allowing the reader unparalleled insight into the structure (and shortcomings) of this experimental tale.

At the end of Learn Python the Hard Way, I was able to make my own Un conte à votre façon program that allowed a reader to move through a “Map” with a pre-established number of scenes. While I was proud of myself for writing a program, I was still not satisfied. I wanted the graph and I wanted it to interact with the program somehow.

My technical lead, Cliff Wulfman introduced me to graphviz, an open source graph (network) visualization project that is freely available for Python. In graph theory, a graph is defined as a plot of nodes and edges. In graphviz as well, in order to make a graph, I had to define all requisite nodes and edges. The program then generates a visualization of the graph that is spatially efficient. As an exercise, I made a graph of the famous graph theory problem of the Bridges of Königsberg.

With this graph theoretical program in my Python arsenal, I was able to make my own graph of Un conte à votre façon. Still not enough, I aimed to integrate the two programs, and Cliff and I decided to give my original program the structure of a graph so that it would be able to generate a graph with graphviz at the end. My program now has nodes and edges that correspond with Queneau’s prompts and choices as follows.

With this structure, I was able to write a program that enters the graph at the first node and, depending on the choice of the user, proceeds through the story, printing out the selected nodes and the corresponding edges. The program records the path the reader takes and at the end, prints out a graph with the reader’s path filled in green, to represent the little peas. While my little program does not take into account the full potential of the intersection of graph theory and literature as proposed by Queneau’s text, I am very pleased with how it functions. For instance, I can leave to the reader the mathematical exercise of finding the minimum number of read-throughs required to hit every node. While there is still more that can be done, the graph my program generates is itself informative — side by side with the text, the reader can learn more about the potential of this three little peas story.