(FILECREATED " 5-Aug-84 23:30:35" {PHYLUM}<HUTTENLOCHER>LISP>COUNTER.;6 3286   

      changes to:  (VARS COUNTERCOMS)
		   (FNS WINVLEXCOUNTS INVLEXCOUNTS)

      previous date: " 4-Aug-84 13:25:26" {PHYLUM}<HUTTENLOCHER>LISP>COUNTER.;3)


(PRETTYCOMPRINT COUNTERCOMS)

(RPAQQ COUNTERCOMS ((FNS INVLEXCOUNTS WINVLEXCOUNTS)))
(DEFINEQ

(INVLEXCOUNTS
  [LAMBDA (HASHTBL FILE)                                     (* edited: " 5-Aug-84 21:32")
    (PROG ((COUNTSTBL (HARRAY 500))
	   (TOTALNUMWORDS 0)
	   (TOTALNUMCLASSES 0)
	   (TOTALEXPECTATION 0)
	   COUNTS NUMWORDS)
          [MAPSTRHASH HASHTBL (FUNCTION (LAMBDA (VAL KEY)
			  (PROG ((SIZE (LENGTH VAL)))
			        (PUTHASH SIZE (ADD1 (OR (GETHASH SIZE COUNTSTBL)
							0))
					 COUNTSTBL)
			        (SETQ TOTALNUMCLASSES (ADD1 TOTALNUMCLASSES))
			        (SETQ TOTALEXPECTATION (IPLUS TOTALEXPECTATION (ITIMES SIZE SIZE]
          [MAPHASH COUNTSTBL (FUNCTION (LAMBDA (CNT SIZE)
		       (push COUNTS (LIST SIZE CNT))
		       (SETQ TOTALNUMWORDS (IPLUS TOTALNUMWORDS (ITIMES SIZE CNT]
          [SETQ COUNTS (SORT COUNTS (FUNCTION (LAMBDA (X Y)
				 (LESSP (CAR X)
					(CAR Y]
          (PRIN1 TOTALNUMWORDS)
          (PRIN1 " words in ")
          (PRIN1 TOTALNUMCLASSES)
          (PRIN1 " classes, expected class size ")
          (PRIN1 (QUOTIENT TOTALEXPECTATION (FLOAT TOTALNUMWORDS)))
          (TERPRI)
          (TERPRI)
          (for CNT in COUNTS
	     do (PRIN1 (SETQ NUMWORDS (ITIMES (CAR CNT)
					      (CADR CNT)))
		       FILE)
		(PRIN1 " words in classes of size " FILE)
		(PRIN1 (CAR CNT)
		       FILE)
		(PRIN1 ", " FILE)
		(PRIN1 (IQUOTIENT (ITIMES NUMWORDS 100)
				  TOTALNUMWORDS)
		       FILE)
		(PRIN1 " %%" FILE)
		(TERPRI FILE])

(WINVLEXCOUNTS
  [LAMBDA (HASHTBL FILE)                                     (* edited: " 5-Aug-84 23:27")
    (PROG ((COUNTSTBL (HARRAY 500))
	   (TOTALNUMWORDS 0)
	   (TOTALNUMCLASSES 0)
	   (TOTALEXPECTATION 0)
	   COUNTS)
          [MAPSTRHASH HASHTBL (FUNCTION (LAMBDA (VAL KEY)
			  (PROG [(SIZE (LENGTH VAL))
				 (WSIZE (for ENTRY in VAL sum (MAX 1 (fetch (LEXENTRY FREQ)
									    ENTRY]
			        (PUTHASH SIZE (IPLUS WSIZE (OR (GETHASH SIZE COUNTSTBL)
							       0))
					 COUNTSTBL)
			        (SETQ TOTALNUMCLASSES (ADD1 TOTALNUMCLASSES))
			        (SETQ TOTALEXPECTATION (IPLUS TOTALEXPECTATION (ITIMES SIZE WSIZE]
          [MAPHASH COUNTSTBL (FUNCTION (LAMBDA (CNT SIZE)
		       (push COUNTS (LIST SIZE CNT))
		       (SETQ TOTALNUMWORDS (IPLUS TOTALNUMWORDS CNT]
          [SETQ COUNTS (SORT COUNTS (FUNCTION (LAMBDA (X Y)
				 (LESSP (CAR X)
					(CAR Y]
          (PRIN1 TOTALNUMWORDS)
          (PRIN1 " words in ")
          (PRIN1 TOTALNUMCLASSES)
          (PRIN1 " classes, expected class size ")
          (PRIN1 (QUOTIENT TOTALEXPECTATION (FLOAT TOTALNUMWORDS)))
          (TERPRI)
          (TERPRI)
          (for CNT in COUNTS
	     do (PRIN1 (CADR CNT)
		       FILE)
		(PRIN1 " words in classes of size " FILE)
		(PRIN1 (CAR CNT)
		       FILE)
		(PRIN1 ", " FILE)
		(PRIN1 (IQUOTIENT (ITIMES (CADR CNT)
					  100)
				  TOTALNUMWORDS)
		       FILE)
		(PRIN1 " %%" FILE)
		(TERPRI FILE])
)
(PUTPROPS COUNTER COPYRIGHT (NONE))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (334 3228 (INVLEXCOUNTS 344 . 1756) (WINVLEXCOUNTS 1758 . 3226)))))
STOP