This site uses cookies for analytics, personalized content and ads. By continuing to browse this site, you agree to this use.


Using SwiftKey to write like Shakespeare

27th December 2010

"Shall I compare thee to  summer's day? Thou art..." Predictions: beloved, bright, much, all, forced, gone, present, comma, not, now, old, more

Hi, I’m Nathan, Global Language Solutions Development Lead at TouchType. My favourite SwiftKey feature is its ability to learn my personal writing style as I type– but did you know that it can also learn from your old text messages? Typing speed can dramatically improve when SwiftKey learns from your SMS. To demonstrate how well SwiftKey learns, I did an experiment: can I use SwiftKey to write like Shakespeare?

Learning from Shakespeare

First, I downloaded a copy of Shakespeare’s Sonnets from Project Gutenberg. Next, I fed the sonnets into Fluency, the clever prediction software which powers SwiftKey. Then, as I wrote, Fluency would predict words in Shakespeare’s sonnet-writing style. Here is a screenshot from the very first quatrain we wrote together:

"Let base clouds stir the world's enshrouded tears / Which have no astronomy to be assail'd / Thus in thy fair appearance lie buried fears / Whose uncovering gaze my fond perceptions failed / And in..." Predictions: my, quest, their, possession, hue, and the

As might be expected from an artificial intelligence, the result is full of mixed metaphors. But it was a fantastic start, and I couldn’t wait to try it on other famous writers.

My next experiment is based on a very old writers’ joke from Alexander Pope’s “An Essay on Criticism” (1709). In this funny and insightful poem, Pope accuses his contemporaries of writing poetry which sounds nice but says very little. The greatest example of beautiful but bankrupt poetry, he imagines, would be a combination of Denham and Waller’s poetic styles.

After training Fluency on the poetic works of Denham and Waller, I could combine their styles for the first time in literary history:

The wise counsels of age shall have the spoil / of art, and elephant, and crown above / when I have seen the..." Predictions: Muses, Greeks, Queen, Earl, British, and English

I had less success with William Gibson. In his novel Neuromancer, Gibson famously uses a style which Allen Ginsberg (inspired by Cézanne) and Rudy Rucker have called the “Eyeball Kick.” This technique creates powerful images by combining two strong words which don’t normally fit together. A classic example from Ginsberg’s poem “Howl” would be “listening to the crack of doom on the hydrogen jukebox.”

Sadly, the very thing which makes SwiftKey so good on smartphones makes it incapable of creating eyeball kicks. Fluency suggests words which are similar to what has already be been said; it’s not designed to predict new, improbable combinations of words.

Despite this setback, I still had fun with Neuromancer. Here’s what happened when I used Fluency to rewrite the famous first line of Gibson’s novel:

"The sky was the color of television tuned to a military facility in Chiba City. The Finn..." Predictions: shrugged, was, and winced

Next, I decided to try one of my favourite epic poems: “Beowulf.” Earlier this year, I enjoyed listening to Dick Ringler’s wonderful translation for modern vocal delivery. How would Fluency handle Beowulf’s rich, Old English poetic form, I wondered? There was only one way to find out. Here is what Fluency and I wrote:

Sing sweetly of battle-borne ages
of fell foes infernal, and the king
whose woe endured hailing rage
and the death of exiled heroes.

Here are the kinds of predictions which Fluency suggested:

"Sing sweetly of battle-borne ages / of fell foes infernal, and the..." Predictions: hoar, King, killing, stronghold, hilt, lives

A Literary Writing Palette

The screenshots of Denham/Waller, Gibson, and Beowulf do include real predictions from Fluency. However, they are visual mock-ups I made for a possible app. Since the concept worked so well, I went on to build a working prototype (which you can see at the top of this post). Now as I write, I can easily select the words which Fluency suggests for a given writer’s style.

Composing poetry with Fluency has changed how I write poetry. I ordinarily write poetry to be spoken; Fluency’s silent suggestions require me to stay at the keyboard.  Virginia Woolf rightly said (in a great BBC broadcast)  that studied poets usually feel the presence of other writers’ words. With Fluency, I sometimes feel as if I have a backseat driver, one who never stops giving very specific suggestions. Sometimes, when Fluency suggests something strange, I search through the training data to learn why that word was suggested. In that way, the original poetry also comes to influence our new poem.

This morning, I finished a complete sonnet influenced by the writing style of Shakespeare. Here it is, edited for style:

SwiftKey Sonnet No 1.
by J. Nathan Matias & the Fluency EngineWhen I in dreams behold thy fairest shade,
Whose shade in dreams doth wake the sleeping morn,
The daytime shadow of my love betrayed
Lends hideous night to dreaming’s faded form;
Were painted frowns to gild mere false rebuff,
Then shouldst my heart be patient as the sands,
For nature’s smile is ornament enough
When thy gold lips unloose their drooping bands.
As clouds occlude the globe’s enshrouded fears,
Which can by no astronomy be assail’d,
Thus thine appearance, tears in atmospheres,
No fond perceptions, nor no gaze unveils.
Disperse the clouds which banish light from thee,
For no tears be true until we truly see.

Further Notes

If you want to learn more about poetry formats (such as sonnets) and how to write them, I highly recommend The Ode Less Traveled, by Stephen Fry.

Stuart Lee, Director of Computer Systems and Services at the Oxford University Computing Services (and Project Director for the excellent First World War Digital Poetry Archive) has recorded a short introduction to Beowulf (mp3), along with a brief parallel reading, in Old English and Modern English.

When I was a postgraduate student at St. John’s College Cambridge, we would gather in the candle-lit Senior Combination Room for an evening of ghost stories, poetry, or ancient literature. It was a magical experience to sit by the fireplace and listen to the Sonnets, in a college founded before Shakespeare’s birth. This beautiful video of Dickens’s Christmas Carol shares a glimpse of that experience with a broader audience.

From time to time, TouchType asks for donations of text to help us improve the quality of predictions in your language. If you are a native speaker of a non-English language and would like to help improve text entry on mobile devices, please contact us using our general enquiries form.

One response to “Using SwiftKey to write like Shakespeare”

  1. Chris Steele says:

    How do you upload a text from Gutenberg for the predictive writing feature?

Leave a Reply