Aug. 20th, 2011

Bard 0.1

Aug. 20th, 2011 10:05 pm
bouteillebleu: (Pocket watch)
Today I have finally started on a programming idea I had a while ago - something that uses the Python Natural Language Toolkit to mess around with poetry.

What I have so far is something that automatically generates (almost) iambic pentameter. It's getting the words from Hamlet at the moment (each pair of words in the output occur next to each other in the play).

It is very bad iambic pentameter, mind, because I'm not taking into account where the emphasis is in words. (There's a dictionary I can use to do this, but I'm not using it yet.) But here's its first creation:

with your sister be pardon and armour
with sleep to stand you his tenders for his
with honesty can well appear like you
with speed to fall a farm it will wear him
with this hand more like madness range as you
with ecstasy of something musty him
with it cannot tell my lowest note him
with equal thanks are naught s cap of frame
with the foils have ta to her virgin as
with entertainment than his base into


As you can see, it's got some way to go. Because the output's random, I can't tell if its love for "with" is accidental or a bug in my code; another few runs of the code should be enough to find out. (The "ta" and "s" are because I'm removing punctuation, which is its own entry in the word lists I'm using - the first is probably from "ta'en".)

Next up - recognising word emphasis properly, possibly using more data and trigrams rather than just bigrams, and likely uploading to Github.

Profile

bouteillebleu: (Default)
bouteillebleu

April 2014

S M T W T F S
  12345
6789101112
13141516171819
20212223242526
272829 30   

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 6th, 2025 12:15 pm
Powered by Dreamwidth Studios