Endorser

WK This is a tool I wrote so that I can easily generate endorsements for http://www.linkedin.com/ - of course it's just a guideline for actually creating one, but "works nice in a crorded area".

 namespace eval end {
        set part0 {
            {an excelent}
            {a brilliant}
            {an intelligent}
            {an experienced}
            {an ambitious}
            {an innovative}
            {a result driven}
            {a highly organised}
            {an independent}
        }

        set part1 {
            {team player}
            {leader}
            {engineer}
            {programmer}
            {software engineer}
            {developer}
            {person}
            {expert}
            {co-worker}
        }

        set part2 {
            {has strong communication skills}
            {very positive attitude towards work}
            {highly recommended}
            {definitely worth recommending}
        }

    proc doendorsement {firstname} {
        variable part0; variable part1; variable part2
        set sentences [expr {2 + int(rand() * 4)}]
        set endorsement ""
        set p0al $part0; set p0alc [llength $p0al]
        set p1al $part1; set p1alc [llength $p1al]
        for {set sentence 0} {$sentence < $sentences} {incr sentence} {
            set p0c [expr {1 + int(rand() * ((6 - $sentences) / 2))}]
            set p0l [list]
            for {set p0 0} {($p0alc > 0) && ($p0 < $p0c)} {incr p0} {
                set idx [expr {int(rand() * $p0alc)}]
                lappend p0l [lindex $p0al $idx]
                if {int(rand() * 10) >= 2} {
                    set p0al [lreplace $p0al $idx $idx]
                    incr p0alc -1
                }
            }
            if {([llength $p0l] > 0) && ([llength $p1al] > 0)} {
                set idx [expr {int(rand() * $p1alc)}]
                #set sntc "[join $p0l {, }] [lindex $p1al $idx]"
                foreach {prefix word} [end_getana [lindex $p0l 0]] break
                if {($sentence == 0) && ($firstname != "")} {
                    set sntc "$firstname is $prefix$word"
                }  elseif {($sentence != 0) && ($firstname != "") && (int(rand() * 10) >= (10-$sentence))} {
                    set sntc "$firstname is $prefix$word"
                }  else  {
                    set sntc $word
                }
                foreach e [lrange $p0l 1 end] {
                    append sntc ", " [lindex [end_getana $e] 1]
                }
                append sntc " " [lindex $p1al $idx]
                if {int(rand() * 10) >= 1} {
                    set p1al [lreplace $p1al $idx $idx]
                    incr p1alc -1
                }
            }
            append endorsement [string totitle $sntc] ". "
        }
        set p2al $part2; set p2alc [llength $p2al]
        set idx [expr {int(rand() * $p2alc)}]
        set sntc [lindex $p2al $idx]
        append endorsement [string totitle $sntc] ". "

        return $endorsement
    }

    proc end_getana {text} {
        set prefix ""
        regexp "^(a |an )(.*)\$" $text - prefix text
        return [list $prefix $text]
    }

 }

ramsan: A very nice program. Useful to be used with own name on difficult Monday morning days.

WK: Some time has passed since this page was originally created. The project is now a website, written in PHP, but it was based on this exact code above. The link is http://www.endorser.org/

NEM: This is one of the most cynical programs I've seen in a long time. I love it!

TP: I heartily endorse this program: Endorser did not fail me a single time. Endorser is precise, careful, hard-working and detail oriented colleague that cannot be overestimated. His wide knowledge and experience makes him really valuable asset to the team.