The simplest form of Twitter bot will generate text and then post it to Twitter. Now, of course you must supply your bot with source text if you want it to generate new text. This is the basis of most bot text generation and the model that we will follow. From here, we want to focus on two main things: the algorithm we will use to generate new text, and the way we format the source text to meet the needs of our algorithm. The algorithm we will use here selects source text by moving along cells in a table and appending them to a string.

But what does that mean?

Essentially, we want to create a table of words or “strings” from which the bot will move along and generate text from. We will put our source text into a tabled format and then have our bot move along the cells this text occupies to select the text and append it to the string of words we will have it post. This is better explained with some visuals and tables.

Selection by Row

You can have your bot select text by either moving along the rows of text or the columns. We’ll start with an example table for selection by row, and show an example table for selection by column later.
Roses Hoses Noses Boses
red, wed, led, tired, dead,
violets oubliets pansies tulips
blue true you?
  The way a bot would generate text by row from this table is as follows: it would look at the first row and randomly select between one of the available strings (e.g. ‘Roes’, ‘Hoses’, etc.). It will then move to the next row and select one of those available strings (e.g. ‘are’). It will continue moving down each row and append the selected string to the generated text. The result is a generated string of text it will then tweet out. Some examples of strings generated from the above table would be: Boses are led, pansies are true Hoses are tired, tulips are you? Roses are dead, oubliets are true Roses are wed, tulips are blue Noses are red, violets are true It’s important to note that the contents of each cell don’t have to be restricted to single words. You can have as many words as you like per table cell, but keep in mind that the Twitter character limit is 140 and it will cut off your tweet at the character limit. So, for example, we could have a table like this:
robin sings fox shouts bull exclaims frog bellows
the song a tale a story the history a remembrance
a lost love. the last cookie. a joyous day. a rainy afternoon.
  Examples of the above table would look like: The fox shouts a remembrance of a rainy afternoon. The frog bellows the song of the last cookie. The bull exclaims the history of a rainy afternoon. The robin sings a tale of a joyous day. The fox shouts a story of a lost love.

Selection by Columns

Selection by columns works the same as selection by row, only instead of moving through rows, the bot will move through columns. Let’s look at an example:
Roses are red, violets are blue
Hoses wed, oubliets true
Noses led, pansies you?
Boses tired, tulips
  As you can see, we have the same set of strings for our bot to generate text from, but now in a slightly different formatting. The bot will begin at the first column (on the far left) and select a random string before moving to the next column (one to the right), repeating until it reaches the end. This will generate the same sets of generated text as the selection by rows would: Hoses are dead, tulips are you? Boses are red, oubliets are blue Roses are led, pansies are true Roses are wed, violets are true Noses are tired, tulips are blue Let’s try a different example to better show the differences:
The plums grow on the long branch.
The apples evolve skinny vine.
The grapes develop fragile
  The bot follows the same process for generating text as in the previous example: start at the left-most column, select a random string, then move one column left, select a random string, repeat. You can make these tables as large as you need, just bear in mind that 140 character limit. Let’s look at some examples generated from the above table: The apples develop on the fragile vine. The plums evolve on the long branch. The apples grow on the elaborate branch. The grapes evolve on the delicate vine. The grapes grow on the skinny branch.

So what’s the difference?

There is no real difference in the generated text between these two formats. The only thing that changes is the approach and formatting. Ultimately, choosing between one or the other is a matter of personal preference. I personally like the selection by column, as it makes it easier to visualize the sentence structure.

Strengths and uses

The biggest advantage that this style of bot has its simplistic formatting. This allows it to be used in a variety of ways, involving massive word lists and generating somewhat complex sentence structure, while still being easily approachable. Any kind of sentence or prose where you might want to replace certain words or elements has potential to be implemented in this style of bot.


Unfortunately, the simplicity of this bot is also its weakness, as it is difficult to make more complex sentence structures. For instance, if I wanted to make certain words or phrases be linked to one another (e.g. ‘roses’ could be linked to ‘red’), this type of bot doesn’t have that capability, as each set of strings is selected randomly. In addition, if I wanted to repeat a particular selected word (e.g.. using ‘red’ more than once, guaranteed), I wouldn’t be able to use this method of bot. For example, a sentence along the lines of “Roses are red. Red roses are my favorite.” would be impossible to generate reliably, due to the random nature of the selection involved in this bot.

To bring everything together…

So, we’ve covered how to generate text by formatting some set of source text into a table according to your preferred method of selection: by row or by column. You can occupy these cells with whatever kind of text you want, just keep in mind the method by which text will be generated from it. Later in this series we’ll show a tool for creating these types of bots. For now, feel free to ask us questions about this style of bot in the comments or tweeting us at @DH_UNT. And as always, thanks for reading!

Leave a Reply

Your email address will not be published. Required fields are marked *