This is a description, in both code and prose, of how to generate original poetry on demand using a computer and the Python programming language. It's based upon work done in the London Python Code Dojo with Dan Pope and Hans Bolang. I've taken some of our original ideas and run with them, specifically:

If you re-assemble unrelated lines from different poems into a new poetic structure, you get a pretty convincing new poem.

This is an exercise in doing the simplest possible thing with a program to fool humans into thinking the computer can write poetry. There are two reasons for this:

  • Simple solutions are easy to understand and think about.
  • Simple solutions work well in an educational context.

To be blunt: we're going to use software to automate a sneaky way to create poems. The basic process is simple:

  • Take a huge number of existing source poems (written by humans) and chop them up into their constituent lines. These thousands of lines will be our source material.
  • Work out how the source lines rhyme and group them together into "buckets" containing lines that rhyme with each other.
  • Further categorise the rhymes in each bucket by word ending. For example, sub-categorise the bucket that rhymes with "uck" into slots for "look", "book", "suck" etc.
  • Specify a rhyming scheme. For example "aabba" means lines one, two and five (the "a"s) rhyme with each other, as do lines three and four (the "b"s).
  • Use the rhyming scheme to randomly select a bucket for each letter (for example, one bucket for the "a"s and yet another bucket for the "b"s) and randomly select a line from different word endings for each line in the rhyming scheme.

Here's a practical example of this process in plain English:

Consider the following three poems I just made up:

Poem 1

This is a special poem,
The words, they are a flowing.
It almost seems quite pointless,
Since this poem is meaningless.

Poem 2

Oh, my keyboard is on fire,
Causing consternation and ire.
Since words are cheap and cheerful,
It's going to be quite an earful.

Poem 3

Words are relentless,
They light up minds like fire.
Causing us to express,
Ideas that flow like quagmire.

The rhyming schemes for each poem are as follows:

  • Poem 1: aabb
  • Poem 2: aabb
  • Poem 3: abab

If we cut up the poems into their constituent lines we get:

This is a special poem,
It almost seems quite pointless,
They light up minds like fire.
Since this poem is meaningless.
Causing consternation and ire.
It's going to be quite an earful.
Oh, my keyboard is on fire,
Words are relentless,
Since words are cheap and cheerful,
Causing us to express,
The words, they are a flowing.
Ideas that flow like quagmire.

If we bucket them by rhymes we get the following four groups:

The words, they are a flowing.
This is a special poem,

It almost seems quite pointless,
Words are relentless,
Since this poem is meaningless.
Causing us to express,

They light up minds like fire.
Oh, my keyboard is on fire,
Causing consternation and ire.
Ideas that flow like quagmire.

It's going to be quite an earful.
Since words are cheap and cheerful,

We can further refine the buckets into sub-categories based on word endings:

  The words, they are a flowing.
  This is a special poem,

  It almost seems quite pointless,
  Words are relentless,
  Since this poem is meaningless.
  Causing us to express,

  They light up minds like fire.
  Oh, my keyboard is on fire,
  Causing consternation and ire.
  Ideas that flow like quagmire.

  It's going to be quite an earful.
  Since words are cheap and cheerful,

Notice how all but one of the subcategories contain a single line. This is simply because our source poems are limited in number and length. In the programmed example below we'll be working with tens of thousands of lines of poetry.

To generate a new poem we specify a rhyming scheme for the new poem, for example: aabba. This tells us we need three "a" lines that rhyme with each other and two "b" lines that rhyme with each other. In other words we need two buckets of rhyming lines - from one we'll select three lines, from the other two lines. Given the list above I'll randomly pick the second and third buckets. Given that I don't want to repeat word endings I'll make sure I randomly choose lines from each bucket from a different word-ending subcategory. In the end I get the following lines:

Oh, my keyboard is on fire,
Causing consternation and ire.
Ideas that flow like quagmire.

It almost seems quite pointless,
Since this poem is meaningless.

If I arrange the lines into the aabba rhyming scheme I end up with the finished poem:

Oh, my keyboard is on fire,
Causing consternation and ire.
It almost seems quite pointless,
Since this poem is meaningless.
Ideas that flow like quagmire.

Given such a simple technique, the result is both interesting, meaningful and (almost) poetic.

As already mentioned, the important "poetic sounding" langauge is created by real poets - we're just going to use a Python program to reassemble lines from these poems to make new poetry.

Where can we get such free source material..? Easy, the wonderful resource that is Project Gutenberg.

I've selected the following anthologies as the source material for this project:

I've put plain text versions of these works in the sources directory, and manually removed the prose elements of these files (introductions, titles, author's names etc).

Consuming Source Poetry

First, we need to get a list of all the source files:

In [1]:
from os import listdir
from os.path import isfile, join

mypath = 'sources'

filenames = [join(mypath, f) for f in listdir(mypath) if isfile(join(mypath, f))]

['sources/pg23545.txt', 'sources/pg1322.txt', 'sources/pg228.txt', 'sources/pg22014.txt', 'sources/pg8672.txt', 'sources/pg12759.txt', 'sources/pg1105.txt', 'sources/pg13646.txt', 'sources/pg19221.txt', 'sources/pg8820.txt', 'sources/pg19722.txt']

Next, we need to load each file and extract the lines of poetry into a set of all known lines of poetry:

In [2]:
LINES_OF_POETRY = set()  # All our lines will be added to this set.

for source_file in filenames:  # For each source file...
    with open(source_file) as source:  # Open it as the object 'source'
        for line in source.readlines():  # Now, for each line in the new 'source' object,
            clean_line = line.strip()  # remove all the leading and trailing whitespace from the line,
            clean_line += '\n'  # re-add a newline character,
            LINES_OF_POETRY.add(clean_line)  # and add it to the set of all lines of poetry
print('We have {} unique lines of poetry.'.format(len(LINES_OF_POETRY)))

We have 65317 unique lines of poetry.

Cleaning and Transforming the Data

In order to re-combine these lines into new poems we need to work out how the lines relate to each other in terms of rhyming. To do this we need to know about phonemes - the sounds that make up speech. The cmudict.0.7a.phones file contains definitions and categorisations (vowel, frictive, etc) of the phonemes used in English:

In [3]:
# Load the phoneme table
with open('cmudict.0.7a.phones') as phoneme_definitions:
    PHONEMES = dict(line.split() for line in phoneme_definitions.readlines())


{'IH': 'vowel', 'P': 'stop', 'ZH': 'fricative', 'T': 'stop', 'D': 'stop', 'Z': 'fricative', 'AH': 'vowel', 'AO': 'vowel', 'OY': 'vowel', 'R': 'liquid', 'AE': 'vowel', 'AW': 'vowel', 'OW': 'vowel', 'EH': 'vowel', 'F': 'fricative', 'L': 'liquid', 'ER': 'vowel', 'AY': 'vowel', 'CH': 'affricate', 'K': 'stop', 'UW': 'vowel', 'JH': 'affricate', 'V': 'fricative', 'Y': 'semivowel', 'S': 'fricative', 'HH': 'aspirate', 'B': 'stop', 'DH': 'fricative', 'M': 'nasal', 'N': 'nasal', 'NG': 'nasal', 'UH': 'vowel', 'IY': 'vowel', 'SH': 'fricative', 'G': 'stop', 'TH': 'fricative', 'EY': 'vowel', 'AA': 'vowel', 'W': 'semivowel'}

Next, we create a simple function to determine if a phoneme is a vowel:

In [4]:
def is_vowel(phoneme):
    A utility function to determine if a phoneme is a vowel.
    return PHONEMES.get(phoneme) == 'vowel'

The cmudict.0.7a file contains a mapping of spelled words to pronunciations expressed as phonemes:

In [5]:
# Create a rhyming definition dictionary
with open('cmudict.0.7a') as pronunciation_definitions:  # Load the CMU phoneme definitions of pronunciation.
    PRONUNCIATIONS = pronunciation_definitions.readlines()


['AARON  EH1 R AH0 N\n', "AARON'S  EH1 R AH0 N Z\n", 'AARONS  EH1 R AH0 N Z\n', 'AARONSON  EH1 R AH0 N S AH0 N\n', 'AARONSON(1)  AA1 R AH0 N S AH0 N\n', "AARONSON'S  EH1 R AH0 N S AH0 N Z\n", "AARONSON'S(1)  AA1 R AH0 N S AH0 N Z\n", 'AARTI  AA1 R T IY2\n', 'AASE  AA1 S\n', 'AASEN  AA1 S AH0 N\n']

We're in a position to create a rhyme dictionary we can use to look up words and discover rhymes.

In [6]:
import re
for pronunciation in PRONUNCIATIONS:  # For each pronunciation in the list of pronunciations,
    pronunciation = re.sub(r'\d', '', pronunciation)  # strip phomeme stresses in the definition (not interesting to us),
    tokens = pronunciation.strip().split()  # get the tokens that define the pronunciation,
    word = tokens[0]  # the word whose pronunciation is defined is always in position zero of the listed tokens,
    phonemes = tokens[:0:-1]  # the phonemes that define the pronunciation are the rest of the tokens. We reverse these!
    phonemes_to_rhyme = []  # This will hold the phonemes we use to rhyme words.
    for phoneme in phonemes:
        if is_vowel(phoneme):
            break  # We only need to rhyme from the last phoneme to the final vowel. Remember the phonemes are reversed!
    RHYME_DICTIONARY[word] = tuple(phonemes_to_rhyme)
print('There are {} items in the rhyme dictionary.'.format(len(RHYME_DICTIONARY)))

There are 132559 items in the rhyme dictionary.

Given that we're rhyming the last word of each line, we need a function to identify what the last word of any given line actually is:

In [7]:
def last_word(line):
    Return the last word in a line (stripping punctuation).

    Raise ValueError if the last word cannot be identified.
    match_for_last_word = re.search(r"([\w']+)\W*$", line)
    if match_for_last_word:
        word = match_for_last_word.group(1)
        word = re.sub(r"'d$", 'ed', word)  # expand old english contraction of -ed
        return word.upper()
    raise ValueError("No word in line.")

The next step is to collect all the lines from our source poems into lines that all rhyme.

In [8]:
from collections import defaultdict

lines_by_rhyme = defaultdict(list)
for line in LINES_OF_POETRY:
        rhyme = RHYME_DICTIONARY[last_word(line)]
    except (KeyError, ValueError):

LINES_THAT_RHYME = [l for l in lines_by_rhyme.values() if len(l) > 1]

print("Number of rhymes found is: {}".format(len(LINES_THAT_RHYME)))

Number of rhymes found is: 552

The final transformation of the data is to group the individual rhymes into ending words (so all the lines that end in "look", "nook" and "book" are collected together, for example). This well help us avoid rhyming lines with the same word.

In [9]:
for lines in LINES_THAT_RHYME:
    lines_by_word = defaultdict(list)
    for line in lines:
        end_word = last_word(line)


[{'COT': ['Mary, leave thy lowly cot\n', 'Low in the sheltered valley stands his cot,\n', 'But, at nights, yon little cot,\n', "Europe's as well, in every part, castle of lord or laborer's cot,\n", 'Leave your work and leave your cot,\n', 'But scarce his nail had scraped the cot\n'], 'SCOT': ['Irish and Welsh and Scot,\n'], 'CANNOT': ['An old man gathering youthful memories and blooms that youth itself cannot.\n', 'Man or woman, I might tell how I like you, but cannot,\n', 'I charge you forever reject those who would expound me, for I cannot\n', 'And might tell what it is in me and what it is in you, but cannot,\n', 'O I see now that life cannot exhibit all to me, as the day cannot,\n', 'But Conscience cried, "I cannot,--\n', 'When I undertake to tell the best I find I cannot,\n', 'See, he reaches the bridge; ah! he lights it! I am dreaming, it cannot\n'], 'ARARAT': ['With Andes and with Ararat.\n', 'you peering amid the ruins of Nineveh! you ascending mount Ararat!\n', 'On Ararat,\n'], 'FORGOT': ['Remembered or forgot,\n', 'As if his malice were forgot,\n', 'That I in your sweet thoughts would be forgot\n', 'That I in your sweet thoughts would be forgot,\n', "and polish'd arch forgot?\n", "By no encroachment wrong'd, nor time forgot;\n", 'Like some old queen that we had half forgot\n', 'Philon the shepherd, late forgot,\n', 'Do I not think on thee when I forgot\n', 'And am I then forgot--forgot?\n', 'As benefits forgot:\n', 'This, in time will be forgot:\n', 'Though now decayed, tis not forgot,\n', 'Visit, a heart I have forgot,\n', 'Where parents live and are forgot,\n', 'And sung sweet ballads now forgot,\n', 'Loved accents are soon forgot.\n'], 'BOUGHT': ['With blood the dear alliance shall be bought,\n', 'The bride and scepter which thy blood has bought,\n', 'Could you be bribed and bought.\n', 'And which for us with their own blood they bought;\n', "A crown usurp'd, which with their blood is bought!\n", 'And not a bloodless victory was bought;\n', 'Or peace with Troy on hard conditions bought.\n', 'They knew that they were given, not that they bought.\n', 'After-wits are dearely bought,\n', "Your passage with a virgin's blood was bought:\n", "Not one but suffer'd, and too dearly bought\n"], 'SPOT': ['Is by far the prettiest spot.\n', 'Still shuns that hallowed spot;\n', 'Hast thou not seen some spot\n', 'Nor gaze upon the spot;\n', 'But dreaded as a haunted spot.--\n', "Know'st thou some favored spot,\n", 'Do ye not know some spot\n', 'What shadow haunts that vacant spot;\n', 'I saw thee from that sacred spot\n', 'Whose fancy in this lonely spot\n', 'Is there no happy spot\n', 'Yet certain am I of the spot\n'], 'CAUGHT': ['A little child, they caught me as the savage beast is caught,\n', 'In either hand the hastening angel caught\n', 'A glimpse through an interstice caught,\n', 'In the Mendocino woods I caught.\n', 'Knowledge he only sought, and so soon caught,\n', 'And golden bowls from burning altars caught,\n'], 'GOTT': ["Luther's strong hymn Eine feste Burg ist unser Gott,\n"], 'ROT': ['Like common earth can rot;\n', 'The barren soil, the evil men, the slag and hideous rot.\n', 'Forever in that hungry hole and rot,\n'], 'JOT': ['Which whips and cudgels neer increased a jot,\n'], 'PLOT': ['(As if his highest plot\n', 'Every path and every plot,\n', 'And he dreamed he were king of the whole garden plot,\n', 'Daily, with souls that cringe and plot,\n', 'Why should my heart think that a several plot,\n', 'In some melodious plot\n'], 'NOT': ['The stranger might smile but I heeded him not,\n', 'Perfume which on earth is not;\n', 'Yet in this deep suspicion rest thou not\n', 'weave, tire not,\n', 'It avails not, time nor place--distance avails not,\n', 'Age might but take the things Youth needed not!\n', 'And as to you Corpse I think you are good manure, but that does not\n', "The life thou lived'st we know not,\n", "Only the theme I sing, the great and strong-possess'd soul, eludes not,\n", 'From rainbow clouds there flow not\n', 'Was not the will kept free? Beheld I not\n', 'The male and female many laboring not,\n', 'Not words, not music or rhyme I want, not custom or lecture, not\n', 'And flowers would notice not;\n', 'I know not, O I know not,\n', 'are nothing--I see them not,\n', "'Gainst the old adversary, prove thou not\n", 'What matters it?--I blame them not\n', "Rose softly in the silence--'Trust him not!'\n", 'Her moving swiftly surrounded by myriads of small craft I forget not\n', "They themselves were fully at rest, they suffer'd not,\n", 'And the Heavens reject not:\n', 'But wilt thou accept not\n', 'Should ye go or should ye not,\n', 'And pine for what is not:\n', 'We understand then do we not?\n', 'What the study could not teach--what the preaching could not\n', 'But here no memory knows them not.\n', 'And in such an hour as you think not\n', 'O my rapt verse, my call, mock me not!\n', 'And miserably sinned. So, adding not\n', "accomplish is accomplish'd, is it not?\n", 'Is war with those where honour is not!\n', 'Thou knowest if best bestowed or not,\n', 'But they fall not?\n', 'He hears the mountain storm and feels it not;\n', 'When ebbed the billow, there was not,\n', 'Nay, if you read this line, remember not\n', 'Delaying not, hurrying not,\n', 'grappling with direst fate and recoiling not,\n', "'The Miller hears and sees not,\n", 'And though my body may not,\n', "A brother's murder. Pray can I not,\n", "The conceits of the poets of other lands I'd bring thee not,\n", 'She bewailed not herself, and we will bewail her not,\n', 'without its friend near, for I knew I could not,\n', 'Draw close, but speak not.\n', 'What thou art we know not;\n', 'I have a temple I do not\n', 'Or mine eyes seeing this, say this is not\n', 'When they said, "Is it hot?" he replied, "No, it\'s not!"\n', 'And longer suffer not.\n', 'Every blue forget-me-not\n', 'As I wend to the shores I know not,\n', 'And me remember not.\n', "This is all remember'd not;\n", 'Nor because those who love thee not\n', 'She heeded not.\n', 'O know you not, O know you not\n', 'So I behold them not:\n', 'The strong base stands, and its pulsations intermits not,\n', 'Glory transcendent that perishes not,--\n', 'How people respond to them, yet know them not,\n', "Work-box, chest, string'd instrument, boat, frame, and what not,\n", 'Yet while I seek but find thee not\n', 'Emblematic and capricious blades I leave you, now you serve me not,\n', 'Try what repentance can: what can it not?\n', 'The choppers heard not, the camp shanties echoed not,\n', 'Who do thy work, and know it not:\n', 'I fled forth to the hiding receiving night that talks not,\n', 'God being with thee when we know it not.\n', "In shackles, prison'd, in disgrace, repining not,\n", 'And sisters live and know us not?\n', "Thou, Washington, art all the world's, the continents' entire--not\n", 'Them that day I saw not.)\n', "The quick-ear'd teamsters and chain and jack-screw men heard not,\n", 'Though I perceive him not.\n', 'One hour to madness and joy! O furious! O confine me not!\n', 'If there I meet thy gentle presence not;\n', "Each who passes is consider'd, each who stops is consider'd, not\n", "Now if a thousand beautiful forms of women appear'd it would not\n", 'I know very well I could not.\n', 'The meanest station owned him not;\n', 'That which man knoweth not.\n', 'And I knew for my consolation what they knew not,\n', 'By the great God of Heaven! It was not\n', "If thou mislike him, thou conceiv'st him not.\n", "Sweet tones are remember'd not;\n", 'That house once full of passion and beauty, all else I notice not,\n', 'Who do thy work, and know it not;\n', 'Then I thought of my sins, and sat waiting the charge that we could not\n', 'Whatever it is, it avails not--distance avails not, and place avails not,\n', 'But ah! so pale, he knew her not,\n', 'And man, at war with man, hears not\n', 'We Sinais climb and know it not.\n', "'Trust him not, Lettice, trust, oh trust him not!'\n", 'I, Jesus, saw thee,--doubt it not,--\n', 'Sail they will not.\n', 'It is safe--I have tried it--my own feet have tried it well--be not\n', 'The Lord is God! He needeth not\n', 'And having thee alone, what have I not?\n', 'Your dreams O years, how they penetrate through me! (I know not\n', 'I see what you do not--I know what you do not.)\n', 'that forgive not,\n', 'Canst thou O cruel, say I love thee not,\n', 'Nay if you read this line, remember not,\n', 'To sympathy with hopes and fears it heeded not:\n', 'To win back to the lines, though, likely as not,\n', 'The blind by-sitter guesseth not\n', 'The Life where Death is not.\n', 'Thou mayst be false, and yet I know it not.\n', "As friend remember'd not.\n", 'When thy friends will miss thee not,\n', "As we wander'd together the solemn night, (for something I know not\n", "You too as a lone bark cleaving the ether, purpos'd I know not\n"], 'TROT': ['The toltering bustle of a blundering trot\n'], 'LOT': ['With a palace and throne, and a crown with a lot\n', 'This thy present happy lot\n', "And order'd you the prize without the lot.\n", 'Meant me, by venturing higher than my lot.\n', 'And reconciles man to his lot.\n', 'Where the quail is whistling betwixt the woods and the wheat-lot,\n', 'Thanksgiving for thy lot;\n', "'Way down in the old meadow lot.\n", 'Now in humbler, happier lot,\n', 'This day be bread and peace my lot;\n', 'Give laws, and dwellings I divide by lot;\n', 'May find a happier lot?\n', 'It spurned him from its lowliest lot,\n', 'And that you know I envy you no lot\n', 'Oh, it was good in that black-scuttled lot\n', "'Tis not through envy of thy happy lot,\n", 'They chain thee to thy lowly lot;\n', "A miser's pensioner--behold our lot!\n"], 'POT': ['Put on the muckle pot;\n', 'To pick out treasures from an earthen pot.\n', 'But they brought it quite hot, in a small copper pot,\n', 'The spring from the fountain now boils like a pot;\n', 'While greasy Joan doth keel the pot.\n', 'And not met with twopence to purchase a pot.\n'], 'SHOT': ['And curst the hand that fired the shot,\n', 'And so here he was lying shot\n', 'Parts, into parts reciprocally shot,\n', 'Not a soldier discharged his farewell shot\n'], 'HOT': ['It ploughs my soul with ploughshares flaming hot--\n', 'Our throats they were parched and hot,\n', "From fibre heart of mine--from throat and tongue--(My life's hot\n", 'Through stones past the counting it bubbles red hot.\n', 'While that the sun with his beams hot\n', 'A stove is a thing that gets awfully hot,\n'], 'SCOTT': ['Tragical glory of Gordon and Scott;\n'], 'GOT': ['Not having thee, what have my labors got?\n', "Says the tinker, I've brawled till no breath I have got\n", 'He now no blossoms got:\n', "How things turned out--the chances! You'd just got\n", 'And the rose herself has got\n', "And all of the apples I've got;\n", 'I went in the fields with the leisure I got,\n', 'O what a mansion have those vices got,\n', "And fries up your meat, or whatever you've got.\n"], 'BLOT': ['Glad hearts! without reproach or blot,\n', "Where beauty's veil doth cover every blot,\n", "But what's so blessed-fair that fears no blot?\n"]}, {'HUMANKIND': ['With words and wicked herbs from humankind\n', 'And Morini, the last of humankind.\n', "Then shew'd the slipp'ry state of humankind,\n"], 'WIND': ['"That I follow the wind.\n', 'I had but a soak and neer rested for wind.\n', 'Beneath the oak which breaks away the wind,\n', "Pleas'd to have sail'd so long before the wind,\n", 'Their words passed by him like the wind\n', 'There let him reign, the jailer of the wind,\n', 'And scudded still before the wind.\n', 'We spread our sails before the willing wind.\n', 'In the sunlight and the wind.\n', 'As, when thick hail comes rattling in the wind,\n', 'They hear a voice in every wind,\n', "Loose was her hair, and wanton'd in the wind;\n", 'the wind,\n', 'The guidon flags flutter gayly in the wind.\n', 'Your warlike ensigns waving in the wind.\n', 'Half doubting whether it be floods or wind,\n', '"Fool!" said the chief, "tho\' fleeter than the wind,\n', 'Surprized by joy--impatient as the wind--\n', "Breathe on our swelling sails a prosp'rous wind,\n", 'Displays, red glowing in the morning wind,\n', 'The speedy Dolphin, that outstrips the wind,\n', 'Unwept, and welter to the parching wind,\n', 'Contract your swelling sails, and luff to wind."\n', 'Invoke the sea gods, and invite the wind.\n', "The course resolv'd, before the western wind\n", 'Nor place--uncertain as the wind;\n', 'Flapping up there in the wind.\n', 'Far in the woods the winter wind\n', 'But little dreaming, as the wakening wind\n', "Striding he pass'd, impetuous as the wind,\n", 'Her Lycian quiver dances in the wind.\n', 'She said, and, sailing on the winged wind,\n', 'Awestruck Ben Isaac stood. The desert wind\n', "We launch our vessels, with a prosp'rous wind,\n", 'Entellus wastes his forces on the wind,\n', "And dancing leaves, that wanton'd in the wind.\n", 'By adverse air, and rustles in the wind.\n', 'O for a soft and gentle wind!\n', 'Spring up in air aloft, and lash the wind.\n', 'moderate night-wind,\n', 'Far, far away from all the world, more rude than rain or wind,\n', "Unmov'd they lie; but, if a blast of wind\n", 'The nodding oxeye bends before the wind,\n', 'Only the ivy and the wind\n', 'Then should I spur though mounted on the wind,\n', 'And some are hung to bleach upon the wind,\n', 'That whistles in the wind.\n', "'Shall she triumphant sail before the wind,\n", 'The distant cries come driving in the wind,\n', 'Blow, blow, thou winter wind,\n', 'Through the velvet leaves the wind,\n', 'moderate wind,\n', 'And belly and tug as a flag in the wind;\n', 'While I see little mouldiwarps hang sweeing to the wind\n', "In meadows fanned by heaven's life-breathing wind,\n", 'The port capacious, and secure from wind,\n', 'To pass the perils of the seas and wind;\n', 'But still as wilder blew the wind,\n', 'noiselessly waved by the wind,\n', 'And as a ship, caught by imperious wind,\n', 'The trumpet of a prophecy! O Wind,\n', 'Keeps off the bothering bustle of the wind,\n', 'Mnestheus pursues; and while around they wind,\n', 'Only flapping in the wind?\n', 'Thy hair soft-lifted by the winnowing wind;\n', 'And first around the tender boys they wind,\n', 'And then another, sheltered from the wind,\n', 'Clouds rack and drive before the wind\n', 'We strive in vain against the seas and wind:\n', 'That she no loss may mourn. And now the wind\n', "The ship flew forward, and outstripp'd the wind.\n", 'It shades his chimney while the singing wind\n', "To flitting leaves, the sport of ev'ry wind,\n", 'Sees God in clouds, or hears him in the wind:\n', 'The streamers waving in the wind,\n', 'Croaking like crows here in the wind.\n', 'She even shuns and fears the bolder wind,\n', 'Pointing to each his thunder, rain and wind,\n', "It stopp'd at once the passage of his wind,\n", 'His cloak of fox-tails flapping in the wind,\n', "And Freedom's fame finds wings on every wind.\n", "Ply like a feather toss'd by storm and wind.\n", 'My stars and stripes fluttering in the wind,\n', 'Sheltered the water from the wind,\n', 'Thus beating up against the wind.\n', 'Still floats upon the morning wind,\n', 'The winged weapon, whistling in the wind,\n', 'Or mount the courser that outstrips the wind.\n', 'Far, far off the daybreak call--hark! how loud and clear I hear it wind,\n', 'As flowers are by the summer wind.\n', 'Love woos her in the summer wind,\n', 'Her age committing to the seas and wind,\n'], 'SIGNED': ["I find letters from God dropt in the street, and every one is sign'd\n", "O this is not our son's writing, yet his name is sign'd,\n"], 'COMBINED': ['His knowledge with old notions still combined\n', 'The powers of health and nature when combined.\n', "Each was a cause alone; and all combin'd\n", "Behold, what haughty nations are combin'd\n", 'Amazement in his van, with flight combined,\n', 'Hearts with equal love combined,\n', "When all th' united states of Greece combin'd,\n"], 'DESIGNED': ["This new invention fatally design'd.\n", 'To seek the shores by destiny design\'d."-\n', "Backward he fell; and, as his fate design'd,\n", "What Turnus, bold and violent, design'd;\n", "This backward fate from what was first design'd?\n", "Virtue, his darling child, design'd,\n", "Nor frauds are here contriv'd, nor force design'd.\n", 'Though not for immortality designed,--\n', "To dare beyond the task he first design'd.\n", "The secret fun'ral in these rites design'd;\n", "And, had not Heav'n the fall of Troy design'd,\n", "The seat of awful empire she design'd.\n", "What friend the priestess by those words design'd.\n", "Ascanius by his father is design'd\n", "An ancient wood, fit for the work design'd,\n", "Came driving on, nor miss'd the mark design'd.\n", "What arms are these, and to what use design'd?\n", "The ways to compass what his wish design'd,\n", "Thinks, and rejects the counsels he design'd;\n", "To color what in secret he design'd.\n", "(Not for so dire an enterprise design'd).\n", "What Jove decrees, what Phoebus has design'd,\n", 'The fatal present to the flames designed,\n', "And soon seduc'd to change what he so well design'd;\n", '"One common largess is for all design\'d,\n', "And, thus deluded of the stroke design'd,\n", "That funeral pomp thy Phrygian friends design'd,\n", "When Priam to his sister's court design'd\n", "Let gifts be to the mighty queen design'd,\n", "Tell me, if she were not design'd\n", "Or seconded too well what I design'd.\n", "Devouring what he saw so well design'd,\n", 'Soar as unfettered as its God designed."\n'], 'CONFINED': ["Had alter'd, and in brutal shapes confin'd.\n", 'By having him confined;\n', "In the dark dungeon of the limbs confin'd,\n", "He said no more, but, in his walls confin'd,\n", 'Freedom, that leaves us more confined,\n', 'A god in love, to whom I am confined.\n', 'Their growing virtues, but their crimes confined;\n', "His pow'r to hollow caverns is confin'd:\n", 'That which her slender waist confined\n', 'Who all my sense confined\n', 'Nor to these alone confined,\n', 'Therefore my verse to constancy confined,\n', 'The heavens thy dwelling, not in bounds confined,\n', 'Are the cares of that heaven-minded virgin confined:\n'], 'HIND': ['Wounds with a random shaft the careless hind,\n', "The plowman, passenger, and lab'ring hind\n"], 'UNDEFINED': ['With thought and semblance undefined,\n'], 'MANKIND': ['O Spirit of all holiness, O Lover of mankind!\n', "'T was but my envy of mankind,\n", 'And shut the gates of mercy on mankind;\n', 'Would make the cannon and the sword the despots of mankind.\n', 'The tutelary genius of mankind\n', 'Once more it knits mankind.\n', 'With the shining thoughts that lead mankind,\n', 'Spent as is this by nations of mankind.\n', 'The dirge and desolation of mankind.)\n', 'Not to build for that which builds for mankind,\n', 'Ring in redress to all mankind.\n', 'Each able to undo mankind,\n', 'Give me the power to labor for mankind;\n', 'Ashes and sparks, my words among mankind!\n'], 'DECLINED': ["And oft on Sundays young men's gifts declined,\n", "But westward to the sea the sun declin'd.\n", "Stupid he sate, his eyes on earth declin'd,\n"], 'REFINED': ["Disturb'd, delighted, raised, refined:\n", 'Tried in sharp tribulation, and refined\n'], 'INCLINED': ["Not forc'd to goodness, but by will inclin'd;\n", "The gods, if gods to goodness are inclin'd;\n", 'Where willows, oer the bank inclined\n', "Thus while he stood, to neither part inclin'd,\n"], 'RIND': ["Such was the glitt'ring; such the ruddy rind,\n"], 'BLIND': ['He would not make his judgment blind,\n', 'From that ill thought; and being blind\n', 'So when the watchful shepherd, from the blind,\n', "Those souls which vice's moody mists most blind,\n", 'Eyes let me be to groping men, and blind;\n', 'So gazing on thy greatness, made men blind\n', "O cunning Love! with tears thou keep'st me blind,\n", 'Shall we say, that Nature blind\n', "O cunning love, with tears thou keep'st me blind,\n", 'Thy heritage! thou eye among the blind,\n', 'Or had not men been fated to be blind,\n', 'Thy heritage, thou eye among the blind,\n', 'And that myself am blind;\n', 'For he was blind.\n', 'Have I been so beguiled as to be blind\n', "He reel'd and was stone-blind.\n", 'In the deep east, dim and blind,\n', 'Poor thing, to be blind;\n', 'Doth part his function, and is partly blind,\n', 'But here, amidst the poor and blind,\n', 'Hunted to death in its galleries blind;\n', 'Him by the throat, and makes him blind,\n', 'Or be you dark, or buffeting, or blind,\n', 'And made him see, who had been blind.\n', "A hawk's keen sight ye cannot blind,\n", "Those that can see thou lov'st, and I am blind.\n", 'All other loves, with which the world doth blind\n', "Is to be pitied; for 'tis surely blind.\n"], 'LINED': ['And velvet mantles with rich ermine lined,\n', 'Through untried roads with ambushes opponents lined,\n', 'You ferries! you planks and posts of wharves! you timber-lined\n', "The gates and walls and houses' tops are lin'd.\n"], 'RESIGNED': ["This pleasing anxious being e'er resign'd,\n", "Of a life that for thee was resign'd!\n", 'But yet, with fortitude resigned,\n', "Then me to Trojan Helenus resign'd,\n", "And the free soul to flitting air resign'd:\n", "The dead is to the living love resign'd;\n", "Driv'n by their foes, and to their fears resign'd,\n"], 'CONSIGNED': ["And when thy sons to fetters are consign'd,\n", "The earth's whole amplitude and Nature's multiform power consign'd\n"], 'INTERTWINED': ['The two old, simple problems ever intertwined,\n', 'Of the empty and useless years of the rest, with the rest me intertwined,\n'], 'PINED': ['Shall my silly heart be pined\n'], 'UNCONFINED': ['Which, nourished on Valhalla dreams of empire unconfined,\n', 'Can speak like spirits unconfined\n'], 'KIND': ["And play the mother's part, kiss me, be kind.\n", 'Kind is my love to-day, to-morrow kind,\n', 'A hospitable realm while Fate was kind,\n', 'A heart as soft, a heart as kind,\n', "Th' eclipse and glory of her kind?\n", "(Such hopes I had indeed, while Heav'n was kind;)\n", "'Cause I see a woman kind;\n", 'Bore Mnestheus, author of the Memmian kind:\n', 'Yearnings she hath in her own natural kind,\n', 'To human kind.\n', 'As every animal assists his kind\n', '(The shady covert of the salvage kind,)\n', 'For thou art covetous, and he is kind,\n', 'Then churls their thoughts (although their eyes were kind)\n', 'Than beauty seeming harmless, if not kind?\n', 'The race and lineage of the Trojan kind,\n', 'Come pour thy joys on human kind;\n', 'Posies from gardens of the sweetest kind,\n', 'Each after his kind.\n', 'Fear ever argues a degenerate kind;\n', '--Though thou art ever fair and kind,\n', "And the world's standing still with all of their kind;\n", 'The bound and suffering of our kind,\n', "Assert the native skies, or own its heav'nly kind:\n", 'Your friend Acestes is of Trojan kind;\n', "Here stood her chariot; here, if Heav'n were kind,\n", 'And rings and jewels of the rarest kind.\n', 'Seen birds of tempest-loving kind--\n', 'And lovely; never since of serpent-kind\n', 'If ever Dido, when you most were kind,\n', 'Be as thy presence is gracious and kind,\n', 'Kind mother have I been, as kind\n', 'When light and sunbeams, warm and kind,\n', 'More grave and true and kind,\n', 'Demurest of the tabby kind\n', 'The handsome and the kind.\n', 'In shapes and forms of every kind\n', 'If not a costly welcome, yet a kind:\n', 'The mind, that ocean where each kind\n', 'Tibris and Castor, both of Lycian kind.\n', "Welcome are all earth's lands, each for its kind,\n", 'Against the relics of the Phrygian kind,\n', 'To purge the world of the perfidious kind,\n', 'Warmed by the Sun, producing every kind;\n', 'Housed in a dream, at distance from the Kind!\n', 'O Love of God most kind!\n'], 'BEHIND': ['They left their outcast mate behind,\n', 'Forsake the seat, and, leaving few behind,\n', 'That thou no form of thee hast left behind,\n', 'Came Salius, and Euryalus behind;\n', 'Evade the Greeks, and leave the war behind;\n', 'Strength in what remains behind;\n', 'And Shame that sculks behind;\n', 'Whom you forsake, what pledges leave behind.\n', 'If Winter comes, can Spring be far behind?\n', 'In Heaven, their earthy bodies left behind.\n', 'Praescious of ills, and leaving me behind,\n', "Comes up, not half his galley's length behind;\n", '"All this, alone, and leaving me behind!\n', 'Close on its wave soothes the wave behind,\n', 'Lights on his feet before; his hoofs behind\n', 'And secret seeds of envy, lay behind;\n', 'And leave the cities and the shores behind.\n', 'And then a little lamb bolts up behind\n', 'Short of his reins, and scarce a span behind)\n', 'Swarm the town: by those who rest behind,\n', 'Nor cast one longing lingering look behind?\n', "For well she knew the way. Impell'd behind,\n", "Ne'er let us cast one look behind,\n", 'All the past we leave behind,\n', 'And never looks behind;\n', 'And holds her shawl, and often looks behind.\n', 'Had parted us, he prayed to come behind.\n', 'loafing on somebody, headway, man before and man behind,\n', 'Not once they turn, but take their wounds behind.\n', 'My grief lies onward and my joy behind.\n', "She shakes her myrtle jav'lin; and, behind,\n", 'Full thirty years behind.\n', 'A precious load; but these they leave behind.\n', '"Ah wretch!" he cried, "where have I left behind\n', 'When ev\'ry weary matron stay\'d behind."\n', 'To leave a memorable name behind.\n', 'To leave some fragment of itself behind.\n', 'Lo! the sun upsprings behind,\n', 'Her cruel fate, nor saw the snakes behind.\n', 'Unsheathes the sword the Trojan left behind\n', 'To pass on, (O living! always living!) and leave the corpses behind.\n', 'Deep Frauds before, and open Force behind;\n', 'Let that which stood in front go behind,\n', 'And waiting ever more, forever more behind.\n', 'Whilst I thy babe chase thee afar behind,\n', 'When the night is left behind\n', 'Still as they run they look behind,\n', "The Danes' unconquer'd offspring march behind,\n", "His crest of horses' hair is blown behind\n", 'And aye the youngest ever lags behind,\n', 'These pleasant names of places but I leave a sigh behind,\n', "Her hand sustain'd a bow; her quiver hung behind.\n", 'But they said, "Never mind! you will fall off behind,\n', 'The ruins of an altar were behind:\n', 'And leave in flames unhappy Troy behind?\n', 'We care not, day, but leave not death behind.\n', 'I will leave the town behind,\n', 'And left the grieving goddess far behind.\n', 'Springs to the walls, and leaves his foes behind,\n', 'Of his fault and his sorrows behind,\n', 'And left so many Grecian towns behind.\n', 'Without, or vapors issue from behind,\n', "Nor is Pygmalion's treasure left behind.\n", 'comes or it lags behind,\n', 'Than what it leaves behind.\n', 'The solemn ape demurely perched behind,\n', 'The tempest itself lags behind,\n', 'All for primal needed work, while the followers there in embryo wait behind,\n', 'That leaves a bit of wool behind,\n', 'And, parting, leave a loathsome stench behind.\n', 'Could leave both man and horse behind;\n'], 'FIND': ["And I, at Heav'n's appointed hour, may find\n", 'By oft predict that I in heaven find.\n', "'O! where shall I my true-love find?\n", 'Sometimes whoever seeks abroad may find\n', 'What speech to frame, and what excuse to find.\n', 'But the fair guerdon when we hope to find,\n', 'And from their lessons seek and find\n', 'Is this the justice which on Earth we find?\n', 'Their friends acknowledge, and their error find,\n', 'Of traitor or of spy, only to find\n', 'Oh, who could wish a sweeter home, or better place to find?\n', 'Nor sleep nor ease the furious queen can find;\n', "Let not my pray'rs a doubtful answer find;\n", 'The hills have echoes; but we find\n', 'In every port a mistress find:\n', 'Where our peace in him we find,\n', 'When all his haughty views can find\n', 'And whisper\'d thus: "With speed Ascanius find;\n', 'Which we are toiling all our lives to find,\n', "In this, our common int'rest, let me find\n", "So foul, that, which is worse, 'tis hard to find.\n", 'He sought them both, but wished his hap might find\n', "All unseen, 'gan passage find;\n", 'Where weary man may find\n', 'And build a household fire, and find\n', "'What from the Delian god thou go'st to find,\n", 'Does straight its own resemblance find;\n', 'Lest eyes well-seeing thy foul faults should find.\n', 'And give the best retreat she hopes to find.\n', 'The woodbine quakes lest boys their flowers should find,\n', 'They snatch the meat, defiling all they find,\n', 'And teach thee how the happy shores to find.\n', 'Its music, lest it should not find\n', 'Lest equal years might equal fortune find.\n', 'The more he thought, the harder did he find\n', "Snatch'd the first weapon which his haste could find.\n", "You are his fav'rite; you alone can find\n", 'The mad prophetic Sibyl you shall find,\n', 'In thy dear self I find--\n', 'In thee his features and his form I find:\n', 'Thinking of roads that travel has to find\n', 'The Pict no shelter now shall find\n', 'Dear spirit, come often and you will find\n', 'Some plausible pretense he bids them find,\n', 'Sweet fellowship they find.\n', 'That in the soul shall its foundations find\n', 'For dearly must we prize thee; we who find\n', 'A Lamb in town thou shalt him find:\n', 'The sun those mornings used to find,\n', "They seize a fleet, which ready rigg'd they find;\n", 'And all expedients tries, and none can find.\n', 'Yet the mistrustless Anna could not find\n', 'With us, one common shelter thou shalt find,\n', 'O what excuse will my poor beast then find,\n', 'I question things, and do not find\n', 'O gentle Reader! you would find\n', 'As in the whole world thou canst find,\n', 'In the labor of engines and trades and the labor of fields I find\n', "Blest, who can unconcern'dly find\n", 'For thee, and for my self, no quiet find.\n', 'And plain enough indeed it was to find\n', 'Say what you want: the Latians you shall find\n', 'And build our fleet; uncertain yet to find\n', 'For Phoebus will assist, and Fate the way will find.\n', 'Of victories but a comma. Fame could find\n', 'O what a happy title do I find,\n', 'Let then wingéd Fancy find\n', 'And on his quest, where likeliest he might find\n', '"What farther subterfuge can Turnus find?\n', 'We will grieve not, rather find\n', 'The yellowhammer loves to find.\n', 'Some sure reward will find;\n', 'Commit to these waste blanks, and thou shalt find\n', 'Of arms, and arras, and of plate, they find\n', 'If not outward helps she find,\n', "Th' unhappy youth? where shall I hope to find?\n", "Sometimes in shell the orient'st pearls we find:--\n", 'Lest eyes well-seeing thy foul faults should find!\n', '"What shall I do? what succor can I find?\n', 'Some new pleasaunce to find;\n', 'Enter, my noble guest, and you shall find,\n', 'That spot which no vicissitude can find?\n', 'And snatches at the beam he first can find;\n', 'But in the thought of Jesus find\n', 'Now voyager sail thou forth to seek and find.\n', 'Aeneas then replied: "Too sure I find\n', 'There, Lord, thy wayworn saints shall find\n', "Th' Italian shores are granted you to find,\n", 'He said (his tears a ready passage find),\n', 'At apple-peelings wanting kisses for all the red fruit I find,\n'], 'ASSIGNED': ["The frighted crew perform the task assign'd.\n", "And a safe passage to the port assign'd.\n", "They scud amain, and make the port assign'd.\n", "And smooth our passage to the port assign'd!'\n", "Whate'er abode my fortune has assign'd,\n", "What place the gods for our repose assign'd.\n", "To drink the dregs of life by fate assign'd!\n"], 'RECLINED': ["Flapped the broad ash-leaves oer the pond reclin'd,\n", 'Broad, red, radiant, half-reclined\n', 'The pensive Selima, reclined,\n', 'While in a grove I sate reclined,\n', 'Through; where the maidens they reclined\n', "Dark in a cave, and on a rock reclin'd.\n"], 'GRIND': ['Mine appetite I never more will grind\n', 'Yet while the cloud-wheels roll and grind\n', "Then with their sharpen'd fangs their limbs and bodies grind.\n"], 'TWINED': ["This said, a double wreath Evander twin'd,\n"], 'MIND': ['unnamed lost ever present in my mind;\n', 'This way and that he turns his anxious mind;\n', 'Forbid the sigh, compose my mind,\n', "When war shall cease, and man's progressive mind\n", 'Of tranquil happy mind,\n', 'To whom the Sibyl thus: "Compose thy mind;\n', 'The cause unknown; yet his presaging mind\n', 'All symptoms of a base ungrateful mind,\n', "She'd something more than common on her mind;\n", 'The dire event, with a foreboding mind.\n', 'And much he blames the softness of his mind,\n', 'Who tempt with doubts thy constant mind:\n', "Nor thought so dire a rage possess'd her mind.\n", 'Lo, the poor Indian! whose untutored mind\n', 'From whence these murmurs, and this change of mind,\n', 'So have I, not unmoved in mind,\n', 'The idol of his musing mind,\n', 'With all thy hart, with all thy soule and mind,\n', 'O change thy thought, that I may change my mind,\n', "Your pity, sister, first seduc'd my mind,\n", 'But Capys, and the rest of sounder mind,\n', 'Instruction with an humble mind.\n', 'They look into the beauty of thy mind,\n', 'And I, for ever telling to my mind\n', 'With anxious Pleasures of a guilty mind,\n', "Why should man's high aspiring mind\n", 'Eternal Spirit of the chainless Mind!\n', 'That cramps and chills the mind,\n', '"Gee hep" and "hoit" and "woi"--O I never call to mind\n', 'For that same groan doth put this in my mind,\n', 'Bring love and music to the mind.\n', 'Haunted forever by the eternal mind!--\n', "What sight can more content a lover's mind\n", "My father's image fill'd my pious mind,\n", "An echo in another's mind,\n", "Thee in thy only permanent life, career, thy own unloosen'd mind,\n", 'In form and beauty of her mind,\n', 'That this presaging joy may fire your mind\n', "On these he mus'd within his thoughtful mind,\n", 'Haunted for ever by the eternal Mind,--\n', 'The envy of a loving mind.\n', '(That last infirmity of noble mind)\n', 'Of both--a noble mind.\n', 'Among the many movements of his mind,\n', 'By turns they felt the glowing mind\n', 'Come visit every pious mind.\n', 'My father, long revolving in his mind\n', "As they could tell each other's mind;\n", "And mollify with pray'rs her haughty mind.\n", 'To wander with an easy mind,\n', 'Besides, long causes working in her mind,\n', 'His birth is well asserted by his mind.\n', 'I know him of a noble mind,\n', 'And doubt and darkness overspread his mind;\n', "Then thus they spoke, and eas'd my troubled mind:\n", "Less oft is peace in Shelley's mind\n", "Enough was said and done t'inspire a better mind.\n", 'Left the sad nymph suspended in her mind.\n', 'Patient the heart must be, humble the mind,\n', 'Thus while he wrought, revolving in his mind\n', 'Was but a dust-spot in a lake: thy mind\n', 'Still whispers to the willing mind.\n', "Were pleasing in your eyes, or touch'd your mind;\n", "Nor let the threaten'd famine fright thy mind,\n", 'Why this unmanly rage? Recall to mind\n', 'Brings fresh into my mind\n', 'And all Aeneas enters in her mind.\n', 'And yet the wiser mind\n', 'Thou mock-truce to the troubled mind,\n', "But in clear auguries unveil thy mind.'\n", 'To reach, and feed at once both body and mind?"\n', 'Then thus she said within her secret mind:\n', "How this may be perform'd, now take my mind:\n", "Thou call'st my lost Astyanax to mind;\n", "Check'd her hand, and changed her mind\n", 'Thus half-contented, anxious in his mind,\n', 'body and the mind,\n', 'But a smooth and steadfast mind,\n', 'Evermore in heart and mind,\n', 'The leash of a sober mind;\n', 'Welcome, where mind can foregather with mind!\n', 'Thou canst not vex me with inconstant mind,\n', 'And larger movements of the unfettered mind,\n', 'And various cares revolving in his mind:\n', 'In health of body, peace of mind,\n', "And, even with something of a mother's mind\n", "Unheard by sharpest ear, unform'd in clearest eye or cunningest mind,\n", 'O Reader! had you in your mind\n', 'To him disclose the secrets of your mind:\n', 'How fleet is a glance of the mind!\n', 'Sleep fled her eyes, as quiet fled her mind.\n', "'What rage,' she cried, 'has seiz'd my husband's mind?\n", 'If he hasn\'t a mind?"\n', 'Bring sad thoughts to the mind.\n', 'He faced the spectres of the mind\n', 'For no progress they find in the wide sphere of mind,\n', "Thus having arm'd with hopes her anxious mind,\n", "If acts of mercy touch their heav'nly mind,\n", "Then to his ardent friend expos'd his mind:\n", 'To kindle vengeance in her haughty mind.\n', "And shake the goddess from their alter'd mind.\n", "Encourag'd much, but more disturb'd his mind.\n", 'Since I left you, mine eye is in my mind,\n', "Love, faithful love recall'd thee to my mind--\n", 'Of patient heart and mind.\n', "Amaz'd he stood, revolving in his mind\n", 'Lo thus by day my limbs, by night my mind,\n', 'And with an empty picture fed his mind:\n', 'The chains of love, or fix them on the mind:\n', 'Is twenty years behind the march of mind.\n', 'This urges me to fight, and fires my mind\n', "By children's eyes, her husband's shape in mind:\n", 'Ring out the grief that saps the mind,\n', 'The dark recesses of his inmost mind:\n', 'And bade to form her infant mind.\n', 'But love hate on for now I know thy mind,\n', 'Such fancies fill the restless mind,\n', 'To swerve from truth, or change his constant mind,\n', "What empty hopes are harbor'd in his mind?\n", 'Swoln with success, and a daring mind,\n', 'In word, and deed, and mind,\n', 'And grief, and joy; nor can the groveling mind,\n', 'To take a new acquaintance of thy mind.\n', "Long tho' it be, 't is fresh within my mind,\n", 'But O! commit not thy prophetic mind\n', 'To soothe his sister, and delude her mind.\n', 'That strength of hand, that courage of the mind,\n', 'My trifles come as treasures from my mind;\n', 'Which brought sweet memories to the mind,\n', 'Of thy chaste breast and quiet mind,\n', 'Wings from the wind to please her mind\n', 'In years that bring the philosophic mind.\n', 'Who would assume to teach here may well prepare himself body and mind,\n', 'Or shake the steadfast tenor of my mind;\n', 'Hums songs of shelter to his happy mind.\n', 'Thee a mistress to thy mind:\n', 'She shall direct thy course, instruct thy mind,\n', "Within his parti-colour'd mind,\n", "Hurrying to war, disorder'd in his mind,\n", 'The toil-worn frame and mind,\n', 'One that will answer to my mind;\n', 'Occasion offers, and excites his mind\n', 'A waking eye, a prying mind,\n', 'Imperial sway no more exalts my mind;\n', "With cheerful words reliev'd his lab'ring mind:\n", 'The vultures of the mind,\n', 'Heed therefore what I say; and keep in mind\n', 'sugar, and be welcome all summer long. They look like things of mind\n', 'Let me be hands and feet; and to the foolish, mind;\n', 'Your image shall be present in my mind."\n', 'She that bears a noble mind\n', 'Give us a name to fill the mind\n', "And even with something of a mother's mind,\n", 'And heaven looked downward on the mind,\n', 'And all things else are out of mind,\n', 'This way and that he turns his anxious mind,\n', 'Yet not to the service of heart and of mind\n', 'Humming of future things, that burn the mind\n'], 'BIND': ['Under that bond that him as fist doth bind.\n', 'The shouting crew their ships with garlands bind,\n', 'And proud Araxes, whom no bridge could bind;\n', 'To heal the broken-hearted ones, their sorest wounds to bind,\n', 'Bare were her knees, and knots her garments bind;\n', 'And poplars black and white his temples bind.\n', 'The heart which love of Thee alone can bind;\n', 'Is this that firm decree which all doth bind?\n', 'A heart that stirs, is hard to bind;\n', 'Shall now my joyful temples bind:\n', 'And holiest sympathies shall bind\n', 'To meet and break and bind\n'], 'UNKIND': ['And all the world appears unkind.\n', 'Tell me not, Sweet, I am unkind\n', 'Thou art not so unkind\n']}]

Generating Poetry

Given the data found in RHYME_DATA we're finally in a position to reassemble rhyming lines from our source poems to make new poetry.

It's important to make sure that, no matter the content of the final line, we ensure it ends with the correct punctuation. So we make a function to do this for us:

In [10]:
def terminate_poem(poem):
    Given a list of poem lines, fix the punctuation of the last line.

    Removes any non-word characters and substitutes a random sentence
    terminator - ., ! or ?.
    last = re.sub(r'\W*$', '', poem[-1])
    punc = random.choice(['!', '.', '.', '.', '.', '?', '...'])
    return poem[:-1] + [last + punc]

We also need to be able to define a rhyme scheme. For example, "aabba" means the first, second and fifth lines all rhyme (a) and the third and fourth lines rhyme (b). We could, of course write other schemes such as: "aabbaaccaa". Nevertheless, the "aabba" scheme is a safe default.

In [11]:
import random
from collections import Counter

def build_poem(rhyme_scheme="aabba", rhymes=RHYME_DATA):
    Build a poem given a rhyme scheme.
    groups = Counter(rhyme_scheme)  # Work out how many lines of each sort of rhyming group are needed
    lines = {}  # Will hold lines for given rhyming groups.
    for name, number in groups.items():
        candidate = random.choice([r for r in rhymes if len(r) >= number])  # Select candidate rhymes with enough lines.
        word_ends = list(candidate.keys())  # Get the candidate rhyming words.
        random.shuffle(word_ends)  # Randomly shuffle them.
        lines_to_use = []  # Will hold the lines selected to use in the final poem for this given rhyming group.
        for i in range(number):  # For all the needed number of lines for this rhyming group,
            lines_to_use.append(random.choice(candidate[word_ends.pop()]))  # Randomly select a line for a new word end.
        lines[name] = lines_to_use  # Add the lines for the rhyming group to the available lines.

    # Given a selection of lines, we need to order them into the specified rhyming scheme.
    poem = []  # To hold the ordered list of lines for the new poem.
    for k in rhyme_scheme:  # For each rhyming group name specification for a line...
            poem.append(lines[k].pop())  # Simply take a line from the specified rhyming group.
    return terminate_poem(poem)  # Return the result as a list with the final line appropriately punctuated.

Finally, we can call the build_poem function to get a list of the lines for our new poem.

In [12]:
my_poem = build_poem()  # Get an ordered list of the lines encompassing my new poem.
poem = ''.join(my_poem)  # Turn them into a single printable string.

Are these our scepters? these our due rewards?
To every hymn that able spirit affords,
I hear the Hebrew reading his records and psalms,
"For Christ's sweet sake, I beg an alms:"--
We stumble, cursing, on the slippery duck-boards.

Example output:

Breake ill eggs ere they be hatched:
The flower in ripen'd bloom unmatch'd
Sparrows fighting on the thatch.
And where hens lay, and when the duck will hatch.
Though by no hand untimely snatch'd...

You could also change the rhyming scheme too:

In [14]:
my_poem = build_poem('aabbaaccaa')
poem = ''.join(my_poem)

That angry Old Man of Quebec.
Once again, the formless void of a world-wreck
And it means, Sprouting alike in broad zones and narrow zones,
Sleep within these heaps of stones;
My eyes settle the land, I bend at her prow or shout joyously from the deck.
A handsome linen collar, too, without a spot or speck;
_Weave the warp and weave the woof
The little brook heard it, and built a roof
His turret crest, and sleek enamelled neck,
I bless thee. Lord, for this kind check...

In [ ]: