Posted to tcl by dandyn at Sun Nov 24 19:50:18 GMT 2024view raw
- proc wordcount {nr} {
- unset -nocomplain data tmp result word
- set data [lrange $::rss::histBuf end-$nr end]
- putlog [llength $data]
- foreach word [regexp -all -inline {\w+} $data] {
- incr tmp([string tolower $word])
- }
- # make a list of array..
- set result [array get tmp]
- # First sort by name, as a secondary key
- set result [lsort -stride 2 -index 0 $result]
- # Then sort by count, descending, as a primary key
- set result [lsort -stride 2 -index 1 -integer -decreasing $result]
- set exclude {
- after with that from says over more about will have said their
- this they been were into what could first some used than
- till lokalt efter säger inte från under vill flera blir alla vara
- blev fick över kommer nytt just direkt
- mycket måste därför ingen hela utan bakom stora bara igen eller andra allt
- aldrig bättre rätt description
- }
- # Print the values
- putlog "\n[string repeat "=" 3] \[STATS\] [string repeat "=" 23]"
- foreach {w c} $result {
- # word must be at minimum 4 chars long
- if {![regexp {^\w{4,}$} $w]} {continue}
- # word must accur at least this many times or more
- if {$c <= 2} {continue}
- if {[regexp $w $exclude match]} {continue}
- putlog [string repeat " " 4][format "%-10s = %s" $w $c]
- }
- putlog "[string repeat "=" 24]"
- putlog "Last $nr posts..\n"
- }
Add a comment