More on Usenet and Google Groups Posting Frequency.




; Inspired by Xah Lee's analysis of frequency of Usenet newsgroups
; I decided to do same in Newlisp, and to add automatic processing
; and output in the form of modern, graphical user interface.

; Data about frequency of posting is collected from Google's interface
; to Usenet. For example, this is the page on address

; http://groups.google.com/group/comp.lang.pascal/about

;



; That page contains data on the posting frequency on Usenet
; group comp.lang.pascal. Here is the critical part of the
; source of the same page:









  (println "The program shows frequency of Usenet posts.")
  (println "Kazimir Majorinc, Institute for Programming, 2009.")
  (println "Free for non-commercial use.")

  (until (begin (print "\n\n\nNewsgroup [enter for exit]: ")
                (set 'group (replace " " (read-line) ""))
                (empty? group))
    
    ;; Following read-file retrieves the content of the page in
    ;; txt form.
    
    (let ((f (read-file (format "http://groups.google.com/group/%s/about"
                                group)))
          (data (list))
          (max-posts/year 0))   ; / is just part of the name
      
      (for (year 1980 (first (now)))
        (let (posts/year)
           (for (month 1 12)
           
             ;; extracting information about number of posts in
             ;; given year and month:
             
             (when (find (format "%04d-%02d\">(.*)<" year month) f 0)
                (inc posts/year (int (replace "&nbsp;" (copy $1) "")))))
                        
           (when posts/year
             (push (list year posts/year) data -1)
             (set 'max-posts/year (max posts/year max-posts/year)))))
       
       ;; Display - if it doesn't look good with your font,
       ;; replace \219 with something else, for example #
       
       (unless (zero? max-posts/year)
          (println "\n ^ posts/year (max = " max-posts/year ")\n |")
          (for (i 20 1 -1)
            (println " |"
               (apply append
                      (map (lambda(x)
                              (if (> (x 1)
                                     (* i (/ max-posts/year 20)))
                                  "\219\219 "
                                  "   "))
                            data))))
          (print " +" (dup "--+" (length data) ) "-->\n ")
          (dolist (j data)
             (print " " (slice (string (j 0)) 2))))))
          
  (exit)


               
;; You need installed Newlisp v10 to run this program.

;; The result will be as on the following picture:



;; Also, program will work for all "Google Groups," not only Usenet Groups.
   
   

     
     
     




---

8 comments:

  1. I get this error:

    Newsgroup [enter for exit]: comp.lang.ruby

    ERR: symbol is protected in function replace : $1

    Using newLISP v.10.3.2 on OSX IPv4/6 UTF-8.

    ReplyDelete
  2. Obviously something changed in last two years, probably google page format.

    ReplyDelete
  3. OK, I just updated it - Newlisp changed, not Google. Now it should work again.

    ReplyDelete
  4. For some strange reason the program works perfectly in newLISP v.10.0.1 on Win32 but fails with the error that Sam received in newLISP v.10.3.3 on Win32.

    ReplyDelete
  5. Sorry, I hadn't refreshed my webpage before you posted. :P

    ReplyDelete
  6. Yes, I replaced $1 with (copy $1) and it works again. Obviously Lutz made $1, ... immutable in the meantime.

    ReplyDelete
  7. I also updated it, replacing hard coded 2009 with (first (now)); now it works to current date.

    ReplyDelete