Posted to tcl by dandyn at Sun Nov 24 19:50:18 GMT 2024view raw

  1. proc wordcount {nr} {
  2.  
  3. unset -nocomplain data tmp result word
  4. set data [lrange $::rss::histBuf end-$nr end]
  5. putlog [llength $data]
  6.  
  7. foreach word [regexp -all -inline {\w+} $data] {
  8. incr tmp([string tolower $word])
  9. }
  10.  
  11. # make a list of array..
  12. set result [array get tmp]
  13.  
  14. # First sort by name, as a secondary key
  15. set result [lsort -stride 2 -index 0 $result]
  16. # Then sort by count, descending, as a primary key
  17. set result [lsort -stride 2 -index 1 -integer -decreasing $result]
  18.  
  19. set exclude {
  20. after with that from says over more about will have said their
  21. this they been were into what could first some used than
  22. till lokalt efter säger inte från under vill flera blir alla vara
  23. blev fick över kommer nytt just direkt
  24. mycket måste därför ingen hela utan bakom stora bara igen eller andra allt
  25. aldrig bättre rätt description
  26. }
  27.  
  28. # Print the values
  29. putlog "\n[string repeat "=" 3] \[STATS\] [string repeat "=" 23]"
  30.  
  31. foreach {w c} $result {
  32. # word must be at minimum 4 chars long
  33. if {![regexp {^\w{4,}$} $w]} {continue}
  34. # word must accur at least this many times or more
  35. if {$c <= 2} {continue}
  36. if {[regexp $w $exclude match]} {continue}
  37.  
  38. putlog [string repeat " " 4][format "%-10s = %s" $w $c]
  39. }
  40. putlog "[string repeat "=" 24]"
  41. putlog "Last $nr posts..\n"
  42. }
  43.  

Add a comment

Please note that this site uses the meta tags nofollow,noindex for all pages that contain comments.
Items are closed for new comments after 1 week