Automatic Haiku Generation

in #programming7 years ago (edited)

Haiku Generator

A few months ago, I wrote a Haiku Generation script in PHP. The parser takes a text file (as large as possible) and separates it into sentences. It then uses some open source code by David Child https://github.com/DaveChild/Text-Statistics to split the data into sentences of five and seven syllables. Finally it combines random selections of five - seven - five syllable sentences. Predictably, the results are hit and miss.

Below, I’ve included some of the better results from some classics downloaded from Project Gutenberg.

Moby Dick

Thus goes the legend
The boat soon picked them up
I sat at the feet

"With what?" shouted I
Never say it anywhere
Starbuck, drive'em aft

"It's very queer
La! la, ma'am!--Mistress! murder! Mrs
Thus goes the legend


Ulysses

Nations of the earth
Whew! Girl in Meath street that night
All that for nothing

Say they won't eat pork
They call it reincarnation
Immortal lovely

The word known to all men
Part shares and part profits
Thieves rob the slain

Insolent driver
Laughter of men from the lane
Now! (He knots the lace)

Influential friends
Won a bit on the races
Sit down a moment

Water to water
Ought to be flowers of sleep
Here see lost love

It was pairing time
Wonder how he looks at life
But this is the point

--Alas, Stephen said
--There it is, Red Murray said
Dignam's potted meat

--Peasoup, Maggy said
I need not mention names
They are lovely

Poisonous berries
A friend of mine sent me
In the shady wood

Mrs Beaufoy, Purefoy
Carriage probably
Deadly agony

Useless: can't move
Devour contents in the street
A bit off the top

But it was lovely
Laughter of men from the lane
Old England is dying

The oldest people
Lay it on with a trowel
Curiosity

Catches the eye, you see
I'm all clean come and dirty me
That causes movement

If it was it was
Don't forget to pray for him
His plump body plunged


War and Peace

I'll drive them out
"Now, look out, master!" he cried
"They can't do anything

Napoleon frowned
27th November I got up late
"Thank God!" said the voice

Traitor, he sold Christ
"Thank God," said his son smiling
"I'm not such a fool”


The Adventures of Huckleberry Finn

!!! Richard III
But he took the pen and wrote
No sign of a boat

They backed water
Too much like jewelry
It was just dark now

I just give up then
Well, I felt better right off
Anybody would


War of the Worlds

That's why I watched you
We must watch these Martians
Play cricket, perhaps

"I came," she said
"It wants showing up," he said
Others did the same


Sort:  

Very nice job. Keep it up.

Coin Marketplace

STEEM 0.20
TRX 0.25
JST 0.039
BTC 97549.65
ETH 3484.99
USDT 1.00
SBD 3.21