(defun terminal (sy) (or (eq sy '|.|) (eq sy '|!|) (eq sy '|?|) (eq sy '|:|))) ;; Is it written by Henley? The parameter is a file name. (defun henleyp (fi) (let ((buffer (make-string maxword)) (pos 0) (nwls nil) (nw 0)) (with-open-file (s fi :direction :input) (do ((c (read-char s nil :eof) (read-char s nil :eof))) ((eql c :eof)) (if (or (alpha-char-p c) (char= c #\')) (progn (setf (aref buffer pos) c) (incf pos)) (progn (unless (zerop pos) (incf nw) (setf pos 0)) (let ((p (punc c))) (when p (if (terminal p) (progn (push nw nwls) (setf nw 0)) (incf nw)))))))) (anal-cwlist nwls))) (defun hispos (x r mn n) (let ((p (truncate (- x mn) r))) (if (= p n) (- p 1) p))) (defun nstar (n) (make-string n :initial-element #\*)) (defun anal-cwlist (cwls) (let ((mx (apply #'max cwls)) (mn (apply #'min cwls)) (a (make-array 5 :initial-element 0))) (if (< 60 mx) (progn (format t "more than 60 words in one sentence.~%") t) (let ((r (/ (- mx mn) 5))) (dolist (x cwls) (incf (aref a (hispos x r mn 5)))) (let* ((j mn) (hmax (max (aref a 0) (aref a 1) (aref a 2) (aref a 3) (aref a 4))) (n* (/ hmax 20.0))) (format t "* = ~A sentences~%" (if (< n* 1.0) 1.0 n*) ) (dotimes (i 5) (format t "~2D-~2D:~A~%" (truncate j) (+ (truncate (incf j r)) (if (= i 4) 1 0)) (nstar (if (< n* 1.0) (aref a i) (truncate (/ (aref a i) n*))))))) (if (< (aref a 3) (aref a 4)) t nil)))))

Red ink makes paper red.

The earth moves around the sun.

If the sentences are short, a sentence that is twice as long as other sentences appears.

In sentences written by Henly, the maximum length of each sentence gets longer as total length of sentences increases. On the other hand, the value is not depend on the total lenght of the sentence (max is ca. 50 words).

henleyp

henleyp

t

if a sentence with more than 60 words exists. if the number of sentences in the last column is larger than that in the 4tth one.

> (henley "original.txt" "henley1000.txt" 1000) ;making a sentence with 1000 words from original.txt NIL > (henley "original.txt" "henley100.txt" 100) ;making a sentence with 100 words from original.txt NIL > (henleyp "original.txt") ;Does Henley write original.txt? * = 5.4500003 sentences 1-11:****************** 11-21:******************* 21-32:******** 32-42:*** 42-54:* NIL ;The function says No > (henleyp "henley100.txt") ;Does Henley write henley100.txt? * = 1.0 sentences 5-12:** 12-19:* 19-27: 27-34: 34-43:* ; There is a long sentence. T ; The program says Yes > (henleyp "henley1000.txt") more than 60 words in one sentence. T ;The program says Yes