Slashdot Mirror


Can You Create An Intelligent Haiku Generator?

BlueCalx- writes: "dotcomma has created a new programming contest: this time, to determine whether or not someone can create a program that can automatically parse an RDF file and generate a haiku based on its headlines or stories. Slashdot users such as 575 have essentially been doing the same thing for months: now, it's time to see if a computer program can do the same thing *g*. After witnessing the success of the AI Bots challenge a few months ago, it'll be interesting to see if a program like this is possible." Anyone who can generate intelligible, germane haiku from headlines without human intervention has my respect -- it's a lot thornier than it sounds.

4 of 211 comments (clear)

  1. Genhaiku. by Anonymous Coward · · Score: 5

    There once was a hacker from Haifa
    Who wrote generator of haiku.
    But an error he made,
    And the program instead
    Generates bad limericks. Gosh, how come?

  2. Rorshack Text != Intelligent by Jon+Peterson · · Score: 5

    As we know, humans have a remarkable ability to determine meaning and pattern where there is mere randmoness and co-incidence. Hence the shapes in clouds, and the pictures in ink blots.

    The Haiku, being a very minimalist form, allows the brain of the reader to fill in so many gaps in the sense of the language that there is room to create entire meaning where none is intended.

    Thus, as with Elisa, the cleverness of haiku generators lies less in the programming, and more in the linguistic observation regarding the nature of the text produced.

    Not, of course, to say that writing haiku generators isn't fun and worthwhile. But's let's not call them intelligent, because firstly they aren't, and secondly we should marvel more at humans' ability to synthesise meaning and pattern and less at computers' ability to imitate it.

    --
    ----- .sig: file not found
  3. Haiku generator written in REXX by mutende · · Score: 5
    Perhaps the following could serve as inspiration:

    #!/usr/bin/rexx
    /****** Haiku.rexx *************************************************
    *
    * $VER: Haiku 2.0 (6.5.95) -- Generates pseudo-random Haiku poems
    *
    ************************************************** ******************/

    dummy = InitVocab()
    dummy = time('l')
    rseed = right(dummy,length(dummy)-lastpos('.',dummy))
    dummy = random(,,rseed)
    say '0A'x || GenHaiku()
    exit 0

    GenHaiku:
    t = random(1,num_templates)
    parse var tem.t line.1 '+' line.2 '+' line.3
    out. = ''
    do i = 1 to 3
    do while length(line.i)>0
    parse var line.i cmd 3 qual 4 line.i
    c = left(cmd,1)
    ucmd = translate(cmd)
    if v.ucmd "" then
    do
    w = word(v.ucmd,random(1,words(v.ucmd)))
    if datatype(c,'u') then
    w = translate(left(w,1)) || substr(w,2)
    c = translate(c)
    if c = 'V' & qual = '@' then
    w = add_ing(w)
    else if c = 'N' & qual = 's' then
    w = pluralize(w)
    else
    line.i = qual || line.i
    end
    else if c = '#' then
    do
    parse value cmd || qual || line.i with '#' list '#' line.i
    say list
    wordslist = words(list)
    say wordslist
    rand_word = random(1,wordslist)
    say rand_word
    w = word(list,rand_word)
    say w
    /*w = word(list,random(1,words(list)))*/
    end
    else
    parse value cmd || qual || line.i with w 2 line.i
    out.i = out.i || w
    end
    end
    return translate(out.1 || '0a'x || out.2 || '0a'x || out.3 || '0a'x, ' ', '_')

    index: procedure
    haystk = arg(1)
    needle = arg(2)
    do idx = 1 to length(haystk)
    if substr(haystk,idx,1) = needle then do
    return idx
    end
    end
    return 0

    add_ing: procedure
    exc. = 0
    exc.whisper = 1
    exc.wander = 1
    exc.flutter = 1
    exc.wither = 1
    exc.wonder = 1
    exv = translate(arg(1))
    parse value arg(1) with 100-3 l3+1 l2+1 l1
    if index("mbgprndlt",l1) > 0 & index("aeiou",l2) > 0 & index("aeiou",l3) = 0 then
    do
    if exc.exv 0 then
    w = arg(1) || l1
    else
    w = arg(1)
    end
    else if l1 = 'e' then
    w = left(arg(1),length(arg(1))-1)
    else
    w = arg(1)
    return w || 'ing'

    pluralize: procedure expose v.
    exc. = 0
    exc.rose = 1
    exc.breeze = 1
    exc.branch = 1
    exc.beach = 1
    exc.glance = 1
    exc.thrush = 1
    exc.child = 1
    exc.fox = 1
    exc.moss = 1
    exc.sunrise = 2
    exc.lotus = 2
    exc.gecko = 10
    exc.cry = 11
    w = arg(1)
    uw = translate(w)
    do while exc.uw > 0 & exc.uw list = value('v.n'exc.uw)
    w = word(list,random(1,words(list)))
    uw = translate(w)
    end
    if datatype(left(arg(1),1),'u') then
    w = translate(left(w,1))substr(w,2)
    select
    when exc.uw = 0 then w = w || 's'
    when exc.uw = 10 then w = w || 'es'
    when exc.uw = 11 then w = left(w,2) || 'es'
    otherwise
    inform("Invalid pluralize exception" exc.uw)
    exit
    end
    return w

    InitVocab:
    v. = ""
    v.a1 = "quick wild small hot white green blue pink thin old light dark"
    v.a1 = v.a1 "sad deep lost free far slow sharp blunt hard soft damp dry"
    v.a1 = v.a1 "bare tight loose low cold clean proud swift gnarled flat"
    v.a1 = v.a1 "strong weak young dull ill"
    v.a2 = "open lofty empty eager even weary leaden fallen dismal serene"
    v.a2 = v.a2 "languid potent silver awkward shallow pliant simple wrinkled"
    v.a2 = v.a2 "falling waiting sighing smiling dreaming sleeping dying"
    v.a2 = v.a2 "almond jasmine mournful leaping supple"
    v.n1 = "oak tree grove stream brook hill branch rose leaf breeze pool"
    v.n1 = v.n1 "root thrush song moon cry glance flame child fox lamb shell"
    v.n1 = v.n1 "moss cave cliff rock beach shore wave sea hand path bark fern"
    v.n2 = "shadow forest clearing hunter sparrow mountain cavern shelter"
    v.n2 = v.n2 "seagull lantern sunrise gecko welcome egret doorway water"
    v.n2 = v.n2 "prison temple valley spirit soldier blossom lotus maple"
    v.v1 = "walk write sing play look fail stray climb grow speak flow live"
    v.v1 = v.v1 "soar crawl creep stand wake sink swim turn sit jump stink"
    v.v1 = v.v1 "dive strive shine glow fade move crave spin hide writhe"
    v.v2 = "wander desire return whisper decline accept withdraw contend"
    v.v2 = v.v2 "rebel retire despair arise wither wonder bubble flutter grumble"
    v.v2 = v.v2 "enchant descend ascend command"
    v.p1 = "in near past through from"
    v.p2 = "under over behind beyond above below around"
    v.r1 = "where when while as"
    v.l1 = "the this my your his her the the the"
    v.h2 = "Gichin Koshi Raiko the_man a_maid Tanto the_queen Moki R.J. Gorby"
    v.h2 = v.h2 "Sanka the_monk Glad_Child Yoko"
    tem. = ""
    tem.1 = "A1 n1, a2 n1.+L1 a1, a2 n2 v1s.+A1 n1, a1 n2."
    tem.2 = "P2 the a1 n1,+R1 the a2 n2 v1s,+I v1; the n1 v1s."
    tem.3 = "The a1 n1 v1@;+It is the a2 n2.+V2@, I v1."
    tem.4 = "The a2 n1 v1s+R1 a2 n2s v2.+Does the a1 n1 v1?"
    tem.5 = "Not a1, not a2,+H2 comes to the n2.+L1 a1 n2 v1s."
    tem.6 = "A1, a2, a2,+H2 v1s. H2 v2s,+V2@, v1@."
    /*tem.7 = "#Never Always# a1, but a1,+H2 knows #no all# a1 n2s.+#Angry Gladdened#, #he she# v1s."*/
    do i = 1 while tem.i ""
    end
    num_templates = i-1
    return 0

    /*
    ** EOF
    */

    It will generate haikus along the line of:

    Swift lamb, shallow rock.
    This hard, waiting prison hides.
    Low moss, damp mountain.

    Enjoy!


    --

    --
    Unselfish actions pay back better
  4. Computer-Related Haiku by curveclimber · · Score: 5

    You step in the stream,
    but the water has moved on.
    This page is not here.

    -- Cass Whittington

    First snow, then silence.
    This thousand dollar screen dies
    so beautifully.

    -- Simon Firth

    The ten thousand things
    How long do any persist?
    Netscape, too, has gone.

    -- Jason Willoughby

    I know this is all in fun so I'm posting these three that I found at some online contest (posted without permission, sorry).

    The idea, however, that what you are all making are actually haiku is just silly. Yes, there is generally a turn at the end (more of a spinning outward), and yes, there is traditionally a word indicating a season (kigo), but not just the words fall or spring, there were whole catalogs of words with their traditional seasonal indication. Cats, for instance, indicate a haiku about Spring.

    Also, remember the whole 5-7-5 thing comes from Japanese, a language very different from our own. You would be better off trying to write three lines that you could say smoothly in one breath (in other words, not 7 one syllable words). There is so much more involved, though, like alliteration and literary allusions.

    I highly recommend you all go read some *real* haiku by the masters: Basho, Issan, Buson, and Shiki, they will explain what haiku is all about far better than I can.