Archive for April, 2013

Haiku Detector Update


On Monday I posted a quick-and-dirty Haiku Detector Mac application I’d written which finds haiku (in terms of syllable counts and line breaks, not aesthetics) in any given text. Since then I’ve made it less dirty and maybe more quick. It now shows progress when it’s busy looking for haiku in a long text, and gives you a count of the sentences it looked at and the haiku it found. You can also copy all the haiku (Copy All Haiku in the Edit menu) or save them to a file (Save in the File menu.) Here’s where you can download the new version, which should still work on Mac OS X 10.6 and later. And here are a few more haiku I’ve found with it.

There’s only one (not counting a by-line) in the feature articles of the April 27 edition of New Scientist:

Inside a cosy
new gut the eggs hatch and the
cycle continues.

From Flatland: a romance of many dimensions, by Edwin Abbott Abbott:

On the reply to
this question I am ready
to stake everything.

“I come,” said he, “to
proclaim that there is a land
of Three Dimensions.”

Man, woman, child, thing—
each as a Point to the eye
of a Linelander.

This was the Climax,
the Paradise, of my strange
eventful History.

Here are a few more from Flatland which I’m editing this post to add, since I liked them more on the second reading:

Let us begin by
casting back a glance at the
region whence you came.

Therefore, pray have done
with this trifling, and let us
return to business.

Even if I were
a baby, I could not be
so absurd as that.

From Last Chance to See, by Douglas Adams and Mark Carwardine, which I somehow ended up with a text file of many years ago and eventually got a book of:

I’ve been here for five
days and I’m still waiting for
something to go right.

We each went off to
our respective rooms and sat
in our separate heaps.

They’re nocturnal birds
and therefore very hard to
find during the day.

It looked like a great
horn-plated tin opener
welded to its face.

We keep searching for
more females, but we doubt if
there are any more.

The very laws of
physics are telling you how
far you are from home.

Foreigners are not
allowed to drive in China,
and you can see why.

`Just the one left,’ she
said, putting it down on the
ground in front of her.

Yet it was hunted
to extinction in little
more than fifty years.

And conservation
is very much in tune with
our own survival.

And here’s my own haiku about a particularly amusing passage in that book:

Here Douglas Adams
trudges through his anagram:
Sago mud salad.

Charles Darwin’s most popular work, The Formation of Vegetable Mould Through the Action of Worms with Observations on their Habits, only contained 12 mostly-lacklustre haiku, but I like to think this one is a metaphor:

Worms do not always
eject their castings on the
surface of the ground.

Something about lack of worm castings being only skin-deep.

But most of these don’t mention nature or seasons, as haiku should. So here are some from Sylva, or A Discourse of Forest Trees:

Dieu, and thence rode to
Blois and on to Tours, where he
stayed till the autumn.

How graphic, and how
refreshing, is the pithy
point thus neatly scored—

Meteorology, or Weather Explained, by J.G. M’Pherson contains some very poetic-sounding unintentional haiku:

“It’ll pe aither
ferry wat, or mohr rain”—a
poor consolation!

“Beware of rain” when
the sheep are restive, rubbing
themselves on tree stumps.

The brilliant flame, as
well as the smoky flame, is
a fog-producer.

Till ten o’clock the
sun was not seen, and there was
no blue in the sky.

But, strange to say, there
is a healing virtue in
breathing different air.

There is much pleasure
in verifying such an
interesting problem.

Unfortunately, there are no haiku in Dijkstra’s ‘Go To Statement Considered Harmful‘.

The app still uses a lot of memory if you process a novel or two, and may have trouble saving files in that case; It looks like it’s a bug in the speech synthesis library (or my use of it) or simply a caching strategy that doesn’t work well when the library is used in this rather unusual and intensive way. Anyway, if you ever try to save a file and the Save dialog doesn’t appear, try copying instead, and relaunch the program.

Next I think I’ll experiment with finding the best haiku based on the parts of speech at the ends of lines. But first, I’d better start working on the thing I’ve plan to do for the six of hearts.

If you’ve found any nice unintentional haiku, or if you can’t run Haiku Detector yourself but have ideas for freely-available texts it could be run on, let me know in the comments.

, , , , , , , , ,

10 Comments

Five of Hearts: Haiku Detector


A few weeks ago, a friend linked to Times Haiku, a website listing unintentional haiku found in The New York Times, saying ‘I’d actually pay for a script that could check for Haiku in my writings. That would make prose-production a lot more exciting! Who’s up to the script-writing-challenge?’

I knew I could do it, having written syllable-counting code for my robot choir (which I really need to create an explanation page about.) I told her I’d make it that weekend. That was last weekend, when I decided at the last moment to write an article about neutron stars and ISOLTRAP, and then chickened out of that and wrote a poem about it. So I put off the haiku program until yesterday. It was fairly quick to write, so here it is: Haiku Detector. It should work on Mac OS X 10.6 and above. Just paste or type text into the top part of the window, and any detected haiku will appear in the bottom part.

Haiku Detector looks for sentences with seventeen syllables, and then goes through the individual words and checks whether the sentence can be split after the fifth and twelfth syllables without breaking a word in half. Then it double-checks the last line still has five syllables, because sometimes the punctuation between words is pronounced. The Times Haiku-finding program has a database of syllable counts per word, but I didn’t need that since I can use the Mac OS X speech synthesis API to count the syllables. Haiku Detector makes no attempt to check for kigo (season words.)

The first place I looked for haiku was the Wikipedia page for Haiku in English. Due to the punctuation, it didn’t actually find any of the example haiku on the page, but it did find this:

Robert Spiess (Red Moon
Anthology, Red Moon Press,
1996)

How profound. Next, having declared myself contributing troubadour for New Scientist magazine, I fed this week’s feature articles through it, and found:

A pill that lowers
arousal doesn’t teach shy
people what to do

Meanwhile, there are signs
that the tide is turning in
favour of shyness.

So by 4000
years ago, the stage was set
for the next big step.

This heat makes the air
spin faster, so pulling the
storm towards the city.

Some will be cooler
and less humid — suitable
for outdoor sports, say.

The last ones seem almost seasonal.

I needed to stress-test the app with a large body of text, so I grabbed the first novel of which I had the full text handy: John Scalzi‘s Old Man’s War, which I had on my iPad on my lap to read while my code was compiling. This book has at least one intentional haiku in it, which Haiku Detector detected. Apart from that, some of my favourites are:

I hate that her last
words were “Where the hell did I
put the vanilla.”

As I said, this is
the place where she’s never been
anything but dead.

“I barely know him,
but I know enough to know
he’s an idiot.”

She’d find me again
and drag me to the altar
like she had before.

A gaper was not
long in coming; one swallow
and Susan was in.

They were nowhere to
be found, an absence subtle
and yet substantial.

And it stares at me
like it knows something truly
strange has just happened.

I haven’t got up to that fifth one in the novel yet, but it mentions a swallow, which I understand is (when accompanied by more swallows) a harbinger of Spring or Summer depending on which language you get your idioms from, so there’s the kigo.

Next I figured I should try some scientific papers — the kinds of things with words that the Times haiku finder would not have in its syllable database. You probably can’t check this unless your workplace also provides access to Physics Letters B, but I can assure you that the full text of the ISOLTRAP paper about neutron stars does not contain any detectable haiku. However, the CMS paper announcing the discovery of the boson consistent with the Higgs does:

In the endcaps, each
muon station consists of
six detection planes.

As is usual for CMS papers, the author and institute lists are about as long as the paper itself, and that’s where most of the haiku were too. Here are a few:

[102]
LHC Higgs Cross Section
Working Group, in: S.

University
of California, Davis,
Davis, USA

That’s ‘one hundred and two’ in case anyone who doesn’t say it that way was wondering.

And here are some from my own blog. I used the text from a pdf I made of it before the last JoCo Cruise Crazy, so the last few months aren’t represented:

Beds of ground cover
spread so far in front of him
they made him tired.

Apologies to
those who only understand
half of this poem.

I don’t remember
what colour he said it was,
but it was not green.

His eyes do not see
the gruesome manuscript scrawled
over the white wall.

• Lines 1 to 3 have
four syllables each, with stress
on the first and last.

(That’s not how you write a haiku!)

I don’t wear armour
and spikes to threaten you, but
to protect myself.

A single female
to perpetuate the genes
of a thousand men.

Kerblayvit is a
made-up placeholder name, and
a kerblatent cheat.

He wasn’t the first,
but he stepped on the moon soon
after Neil Armstrong.

He just imagined
that in front of him there was
a giant dunnock.

(there are plenty more where that one came from, at the bottom of the page)

She was frustrated
just trying to remember
what the thing was called.

Please don’t consider
this a failing; it is part
of your programming.

While writing this program, I discovered that that the speech API now has an easier way to count syllables, which wasn’t available when I wrote the robot choir. The methods I used to separate the text into sentences and the view I used to display the haiku are also new. Even packaging the app for distribution was different. I don’t get to write Mac software often enough these days.

Yet again, I didn’t even bother to deal out the cards because I already had something to inspire me. In my halfhearted attempt to find a matching card, I came across one about electronics in the service of ALICE, so I ran the latest instalment of Probably Never, by Alice, into it, and got this:

Or well, I have to
put up with getting called a
fake girl all the time.

The jackhole who called
me a “he/she” recognized
that he crossed the line.

If that sounds interesting, subscribe to Probably Never, and I could probably forward you the rest of that episode if you want.

And finally, two unintentional haiku from this very post:

Haiku Detector
makes no attempt to check for
kigo (season words.)

(there are plenty more
where that one came from, at the
bottom of the page)

Wait; make that three!

And finally, two
unintentional haiku
from this very post:

Have fun playing with Haiku Detector, and post any interesting haiku you find in the comments. Also, let me know of any bugs or other foibles it has; I wrote it pretty quickly, so it’s bound to have some.

I know what I’m doing for the six of hearts; I’ve planned it for a long time but still haven’t actually started it. It’s musical, so it will probably be terrible; brace yourselves. By the way, I keep forgetting to mention, but They Might Not Be Giants will be published in Offshoots 12. Yay!

, , , , , , , , , , ,

6 Comments

Four of Hearts: Nucleosynthesis (rapidly processed)


Americium four of hearts, because it's a source of neutrons.Oft upon a spacetime,
a red star gets the blues
and puffs up like a superstar
with nothing left to fuse.
Pushing hot and heavy,
it finds its stellar rise
affords a new and rapid way
to nucleosynthesise.

Squirts new heavy ions
to interstellar dust
then collapses in and pulls some back
and into stellar crust.
Newly Lilliputian,
compressed by weight of all
our star invites its nearest friends
to join the neutron ball.

Millimetre mountains
on kilometres-round
neutron star where mass of more
than one Earth Sun is bound.
Heart a seething chaos,
skin so smooth and hard,
beneath the skin, too densely packed
to tell each piece apart.

Love-crossed star starts dancing
with friend who heard the call:
another star-crossed lover,
another neutron ball.
They pull each other closer,
spin fast, and by and by,
they kiss in bursts of gamma rays
and heavy nuclei.

Once upon a planet
of star-fused chemistry
some humans sought to learn of how
their atoms came to be:
Made their own large nuclides
used traps to measure mass,
then calculated where they’d fit
in star’s electron gas.

Nuclides so unstable
they fall apart on Earth,
at pressure, they survive in dead
star hotbed’s upper berth:
Isotopes of nickel,
and lots of iron too,
zinc-80 (deeper than we thought)
But no zinc-82.

Once upon a line graph,
those data points could show,
a hint of where and when and how
big elements may grow.
Is it supernovas,
or casanovas’ kiss?
Is it neither? Some of both?
And what else did we miss?

Probed big atoms’ origins,
but all their parents knew:
My daughter works in science labs;
don’t ask me what they do!
Tried to tell the physicists
but all that students knew:
zinc-80 (deeper than they thought)
and no zinc-82.

This is my understanding (as a mere mathematician/code monkey) of the cover story of this month’s CERN Courier. I picked up a copy on Friday evening on the way out of work, and decided I could interview people I know in ISOLDE and write an article about it in 400 words or fewer in order to apply for an editorial trainee scheme at New Scientist magazine, since applications weren’t due until Monday and I needed a writing project for the weekend anyway. Once I’d read the article and enough supporting material to understand it, I realised I probably wouldn’t end up writing the article. I wasn’t sure I really understood the significance of it, I didn’t have access to the original paper from home, and what’s more, the result was a month and a half old, which is far too old, according to New Scientist’s freelancing guidelines. It might work for getting an internship at Old Scientist, but I probably wouldn’t like that because I’m the editor-in-chief at Old Scientist and I’d probably treat my interns poorly.

Anyhow, I decided I’d just appoint myself New Scientist’s, or maybe the CERN Courier’s, unofficial contributing troubadour, and write poems about their feature articles. If Popular Science can have a contributing troubadour, so can New Scientist. So, certain I couldn’t adequately explain ISOLTRAP’s result in 400 words or fewer, I set about writing a poem about it, which came out at 302 words. I tackled it rather longitudinally though; it doesn’t go much into the specifics (or even mention the r-process or ISOLTRAP by name) and occasionally I may sacrifice clarity for rhythm or puns, but I tried to give all the context needed to have some kind of understanding of the final result. This article is probably easier to understand than the CERN Courier one. One of the many interesting things I learnt while researching this is that stars actually get the blues before going supernova.

, , , , , , , , ,

Leave a comment

Three of Hearts: Phirmanator: The Sara Chicazul Chronicles


Three of hearts with ALICE, Sara, a die and a robotBack in late February, my friend  Alice sent an email asking people to cover The Doubleclicks’ Nerdy Birthday Song for Sara Chicazul, who had a birthday on JoCo Cruise Crazy 2 but not on JoCo Cruise Crazy 3. The idea was to put up one per day, so that she could experience the thrill and horror (previously reserved for Mike Phirman) of having a birthday every day. A lot of people did. I don’t usually sing anything more melodic than Chicken Monkey Duck when people can hear me, so I figured I’d dust off my robot choir (a little program I wrote to take text and a tune played on my MIDI keyboard, and turn it into TUNE commands to make the built-in Mac speech synthesis sing) and record a cover that way. It took a fair bit of dusting off, what with a new version of XCode and of the MIDI framework I used, and I think the metaphorical dust mites gave me cold-like symptoms, which is why I haven’t posted anything for a while. Anyway, today I finally recorded a cover, and here it is. Given that the third thing I ever recorded using my robot choir was my Macs singing Happy Birthday to the London Science Museum, I think I may as well rename my robot choir to ‘The Phirmanator’.

This recording starts off with just the Victoria voice singing, then at the first ‘you’re getting older’, Vicki joins in. I have a cameo saying ‘everybody!’ and then Agnes joins in and all three voices get a gospel choir effect. I added Zarvox (an intentionally robotic voice) at the end, partly because I thought it would be funny, and partly because Vicki sounds awful holding that ‘all’ note and I wanted to make up for her being so much quieter in that part. I noticed part of the way through that I’d used the wrong notes in a few places, so I fixed those, but there are probably others. I don’t know how to make music; I just know how to turn MIDI notes into frequencies. Also, I can barely even play my rainstick, let alone a stringed instrument, so it’s a robocoppella. I timed everything to synch up with the original song, and it sounds kind of nice if you play both together. By itself, well… it sounds like autotune became sentient and killed all the human singers.

, , , , , ,

Leave a comment

%d bloggers like this: