;ELC ;;; compiled by jwz@thalidomide on Fri May 6 16:37:32 1994 ;;; from file /th/jwz/emacs19/lisp/games/conx.el ;;; emacs version 19.10 Lucid (beta21). ;;; bytecomp version 2.24; 26-Apr-94. ;;; optimization is on. ;;; this file uses opcodes which do not exist in Emacs 18. (if (and (boundp 'emacs-version) (or (and (boundp 'epoch::version) epoch::version) (string-lessp emacs-version "19"))) (error "This file was compiled for Emacs 19.")) (byte-code "!!   LJ" ["1.6, 6-may-94." conx-version boundp conx-bounce 10 conx-hashtable-size 9923 nil conx-words-hashtable conx-words-vector 0 conx-words-vector-fp conx-last-word] 2) (defvar conx-files nil "\ FYI") (fset 'conx-init #[nil "G Y\" \" \"\" Ɖ\n" [conx-words-hashtable conx-hashtable-size fillarray 0 make-vector conx-words-vector nil 1000 conx-words-vector-fp conx-last-word conx-files] 3 "\ Forget the current word-frequency tree." nil]) (byte-code "MMMMMMMMMMMMMM" [conx-rehash #[nil "!\nG \\\" W S\n SHIm*!" [message "Rehashing..." conx-words-vector L make-vector nil v2 0 "Rehashing...done"] 5] conx-count (macro . #[(word) " E" [aref word 0] 3]) conx-cap (macro . #[(word) " E" [aref word 1] 3]) conx-comma (macro . #[(word) " E" [aref word 2] 3]) conx-period (macro . #[(word) " E" [aref word 3] 3]) conx-quem (macro . #[(word) " E" [aref word 4] 3]) conx-bang (macro . #[(word) " E" [aref word 5] 3]) conx-succ (macro . #[(word) " E" [aref word 6] 3]) conx-pred (macro . #[(word) " E" [aref word 7] 3]) conx-succ-c (macro . #[(word) " E" [aref word 8] 3]) conx-pred-c (macro . #[(word) " E" [aref word 9] 3]) 10 conx-length conx-make-word (macro . #[nil "" [(copy-sequence '[1 0 0 0 0 0 nil nil 0 0])] 1]) conx-setf (macro . #[(form val) " ! \"9 E @= A C\"B @= A@ E @= A@ E \"" [macroexpand form boundp byte-compile-macro-environment setq val aref aset append cdr setcdr car setcar error "can't setf %s"] 5]) conx-push (macro . #[(thing list) " EE" [conx-setf list cons thing] 5])] 2) (defconst conx-most-positive-fixnum (byte-code "\"" [lsh -1] 3) "\ The largest positive integer that can be represented in this emacs.") (byte-code "MMMMMM" [conx-rand (macro . #[(n) "E E" [% logand conx-most-positive-fixnum (random) n] 4]) conx-relate-succ (macro . #[(word related) " DDCEDCEEFEF" [let vec symbol-value word (conx-setf (conx-succ-c vec) (1+ (conx-succ-c vec))) rel assq related (conx-succ vec) if (setcdr rel (1+ (cdr rel))) conx-push cons 1 (conx-succ vec)] 12]) conx-relate-pred (macro . #[(word related) " DDCEDCEEFEF" [let vec symbol-value word (conx-setf (conx-pred-c vec) (1+ (conx-pred-c vec))) rel assq related (conx-pred vec) if (setcdr rel (1+ (cdr rel))) conx-push cons 1 (conx-pred vec)] 12]) conx-add-word (macro . #[(word) "\nDDC#" [append (let*) word (fc (aref word 0)) ((setq word (intern (downcase word) conx-words-hashtable)) (let ((vec (and (boundp word) (symbol-value word)))) (if vec (conx-setf (conx-count vec) (1+ (conx-count vec))) (if (= conx-words-vector-fp (length conx-words-vector)) (conx-rehash)) (set word (setq vec (conx-make-word))) (aset conx-words-vector conx-words-vector-fp word) (setq conx-words-vector-fp (1+ conx-words-vector-fp))) (or (< fc 65) (> fc 90) (conx-setf (conx-cap vec) (1+ (conx-cap vec))))) (if conx-last-word (progn (conx-relate-succ conx-last-word word) (conx-relate-pred word conx-last-word))) (setq conx-last-word word))] 4]) conx-punx (macro . #[(char) " DDEE" [if conx-last-word let char (vec (symbol-value conx-last-word)) (cond ((eq char 44) (conx-setf (conx-comma vec) (1+ (conx-comma vec)))) ((or (eq char 46) (eq char 59)) (conx-setf (conx-period vec) (1+ (conx-period vec))) (setq conx-last-word nil)) ((eq char 63) (conx-setf (conx-quem vec) (1+ (conx-quem vec))) (setq conx-last-word nil)) ((eq char 33) (conx-setf (conx-bang vec) (1+ (conx-bang vec))) (setq conx-last-word nil)))] 5]) conxify-internal #[nil "m?wg>wwq`whUu\n`=U\n`{ȚL  H   \"  ! JHTIGU  !L IT W VHTI)JHTI HAT BHBI* JHTIHATBHBI* *Twg>\nJ!=HTI!=!=HTI!=HTI!=HTI**" [nil w p "^A-Za-z0-9'" (48 49 50 51 52 53 54 55 56 57 39) "A-Za-z0-9'" 39 -1 "nil" word 0 fc intern conx-words-hashtable boundp vec conx-words-vector-fp conx-words-vector conx-rehash copy-sequence [1 0 0 0 0 0 nil nil 0 0] 65 90 1 conx-last-word 8 6 rel 9 7 n " \n " (44 46 33 63 59) char 44 2 46 59 3 63 4 33 5] 6]] 2) (fset 'conx-buffer #[nil " \ndeb~` W #`}`b ~_d\"U*C \nZ#+" [conx-words-vector conx-init conx-words-vector-fp 0 pm n i p search-forward "\n\n" conxify-internal message "%d%%..." 100 buffer-file-name conx-files "%s words, %d unique"] 5 "\ Absorb the text in the current buffer into the tree." nil]) (fset 'conx-region #[(p m) "~ } )" [p m conx-buffer] 2 "\ Absorb the text in the current region into the tree." "r"]) (fset 'conx-mail-buffer #[nil "ebw!!m#`#`#` \"W` `\"\nbP-  C)" ["\n " nil p3 p2 p buffer-file-name case-fold-search looking-at "^From " error "not in /bin/mail format" search-forward "\n\n" 0 "\nFrom " re-search-backward "\n--+\n" t count-lines 9 conx-region conx-files] 5 "\ Conxify a buffer in /bin/mail format." nil]) (byte-code "MMM" [conx-random-related #[(count list) "U \"@AX@@ʼni@AZAZ*" [count 0 logand conx-most-positive-fixnum random nil ans foll list] 4] conx-random-succ #[(word) "JHUJHJH\" \" U JH JH\"! )" [word 8 0 conx-random-related 6 next logand conx-most-positive-fixnum random conx-bounce conx-random-succ 9 7] 5] conx-sentence #[nil "V!  \"H\n`   \"J H\n H HU\n!H\\cOc!c HWc HZ HW \"֦U \"צUccc HZ HWc HZ HWcc HU$!) by`)`\"hU \"צUc!c.̇" [conx-words-vector-fp 0 error "no conx data is loaded; see `conx-buffer'." conx-words-vector logand conx-most-positive-fixnum random word t first-p p nil vec punc str 1 symbol-name -32 2 ", " 3 5 4 ": " "; " ". " "? " "! " " " 8 conx-random-succ fill-region-as-paragraph 10 "\n" delete-char -1 " "] 5]] 2) (fset 'conx #[nil "!q!!!!dbhUɪ! l" [display-buffer get-buffer-create "*conx*" select-window get-buffer-window message "type ^G to stop." sit-for 10 2 0 conx-sentence] 3 "\ Generate some random sentences in the *conx* buffer." nil]) (fset 'conx-gnus-snarf #[nil "q~eb#`d\"*" [gnus-article-buffer search-forward "\n\n" nil t conx-region] 4 "\ For use as a gnus-select-article-hook."]) (fset 'psychoanalyze-conx #[nil " !!! ? !U !!d" [doctor message "" switch-to-buffer "*doctor*" sit-for 0 input-pending-p conx-sentence random 2 doctor-ret-or-read 1] 2 "\ Mr. Random goes to the analyst." nil]) (fset 'conx-save #[(file) "!qed|cc#˱ α`cWHp\"cTgc`\"c,\"eb#!s&! ) !*" [nil b get-buffer-create "*conx-save-tmp*" ";;; -*- Mode:Emacs-Lisp -*-\n" ";;; This is a CONX database file. Load it with `conx-load'.\n" conx-files ";;; Corpus: " mapconcat identity ", " "\n" ";;; Date: " current-time-string "\n\n" 78 " " 0 i fill-prefix fill-column p "(!! [ " conx-words-vector-fp prin1 conx-words-vector " " "])\n" fill-region-as-paragraph mapatoms #[(sym) " !??c p\"c Jp\"c" [boundp sym "(! " prin1 " " ")\n"] 3] conx-words-hashtable re-search-forward "\\bnil\\b" t replace-match "()" set-visited-file-name file save-buffer kill-buffer] 6 "\ Save the current CONX database to a file for future retrieval. You can re-load this database with the \\[conx-load] command." "FSave CONX corpus to file: "]) (fset 'conx-load #[(file) " \"M \"KM  !)" [conx-init intern "!!" conx-words-hashtable #[(vec) "G" [vec conx-words-vector conx-words-vector-fp] 2] "!" setq obarray load file] 3 "\ Load in a CONX database written by the \\[conx-save] command. This clears the database currently in memory." "fLoad CONX corpus from file: "]) (byte-code "M!!" [conx-emit-c-data #[(&optional ansi-p) "p \n  ! \")  G_! !إ إ] c@AJH T@A!c@@ \"@!cTVcAO \n\" TH@A!c@@ \"@!cTVcAO \n\" TA_,c )*@A!GT))\\*)\\\\*V.嬨c)\\*cc \n\" TA5-c ω34*S@44A!34AJcH!cH!cH!cH!cH!cH!Hcc!HG_\\Hcc!cHG_\\H!cH!c*!*3G\\\\*A4@Uc \n\" TAw.c?!c@!.\n" [nil "%.2f" total100 total count float-output-format before-change-function after-change-function before-change-functions after-change-functions standard-output all conx-words-hashtable error "no words" 0 i mapatoms #[(x) " !\n B B\nT" [boundp x i all] 2] 4 1 featurep lisp-float-type float 100 5 word rest2 rest "static unsigned short D[] = {" 7 princ "," rassq 10 "\n" message "Writing C code... %s%%" 6 "0};\nstatic char T[] = \"" 20 k j symbol-name 3 77 ansi-p "\"\n\"" "\\\n" "\\000" "\";\nstatic struct conx_word words [] = {" name cons "{" 2 ",0" ",0," 9 8 "},\n" "}," "}" "};\n#define conx_bounce " conx-bounce "Writing C code... done."] 11] boundp conx-c-prolog "#if __STDC__\n#include \n#include \nextern long random (void);\nextern void srandom (int);\nextern void abort (void);\n#endif\n#include \n#include \n\nstruct conx_word {\n unsigned short count;\n unsigned short cap;\n unsigned short comma;\n unsigned short period;\n unsigned short quem;\n unsigned short bang;\n unsigned short pred;\n unsigned short succ;\n unsigned short npred;\n unsigned short nsucc;\n unsigned short text;\n};\n" conx-c-code "#define countof(x) (sizeof((x)) / sizeof(*(x)))\n#define conx_rand(n) (random()%(n))\n\nstatic struct conx_word *\nconx_random_related (count, which_list)\n unsigned short count, which_list;\n{\n unsigned short *list = D + which_list;\n int i = 0;\n unsigned short foll = (count == 0 ? 0 : conx_rand (count));\n while (1)\n {\n if (foll <= list [i * 2])\n {\n if ((list [i * 2 + 1]) > countof (words))\n abort ();\n return &words [list [i * 2 + 1]];\n }\n foll -= list [i * 2];\n i++;\n }\n}\n\nstatic struct conx_word *\nconx_random_succ (word)\n struct conx_word *word;\n{\n if (word->nsucc == 0)\n return word;\n else\n {\n struct conx_word *next = conx_random_related (word->nsucc, word->succ);\n if (conx_rand (conx_bounce) != 0)\n return next;\n return conx_random_succ (conx_random_related (next->npred, next->pred));\n }\n}\n\nstatic void\nconx_sentence ()\n{\n static int x = 0;\n struct conx_word *word = 0;\n int first_p = 1;\n int done = 0;\n int count = 0;\n while (!done)\n {\n int punc;\n char *text;\n int L;\n if (word)\n word = conx_random_succ (word);\n else\n word = &words [conx_rand (countof (words))];\n count++;\n punc = conx_rand (word->count);\n text = T + word->text;\n L = strlen (text);\n if (x + L > 70)\n {\n putchar ('\\n');\n x = 0;\n }\n x += L+1;\n\n if (first_p || (word->count == word->cap))\n {\n putchar ((*text >= 'a' && *text <= 'z') ? *text + ('A'-'a') : *text);\n fputs (text+1, stdout);\n first_p = 0;\n }\n else\n fputs (text, stdout);\n\n if (punc < word->comma)\n {\n fputs (\", \", stdout);\n x++;\n }\n else if ((punc -= word->comma) < word->period)\n {\n x++;\n if (count > 120 || conx_rand (5) != 0)\n {\n done = 1;\n fputs (\". \", stdout);\n x++;\n }\n else\n {\n word = 0;\n if (conx_rand (4) == 0)\n fputs (\": \", stdout);\n else\n fputs (\"; \", stdout);\n }\n }\n else if ((punc -= word->period) < word->quem)\n {\n done = 1;\n fputs (\"? \", stdout);\n x += 2;\n }\n else if ((punc -= word->quem) < word->bang)\n {\n done = 1;\n fputs (\"! \", stdout);\n x += 2;\n }\n else\n {\n if (word->nsucc == 0)\n {\n fputs (\". \", stdout);\n x += 2;\n done = 1;\n }\n else\n putchar (' ');\n }\n }\n if (conx_rand (3) == 0)\n {\n fputs (\"\\n\\n\", stdout);\n x = 0;\n }\n}\n\nmain (argc, argv)\n int argc;\n char **argv;\n{\n unsigned int howmany, delay;\n char dummy;\n if (argc == 1)\n {\n howmany = 1;\n delay = 0;\n }\n else if (argc == 2 &&\n 1 == sscanf (argv[1], \"%ud%c\", &howmany, &dummy))\n delay = 0;\n else if (argc == 3 &&\n 1 == sscanf (argv[1], \"%ud%c\", &howmany, &dummy) &&\n 1 == sscanf (argv[2], \"%ud%c\", &delay, &dummy))\n ;\n else\n {\n fprintf (stderr, \"usage: %s [count [delay]]\\n\", argv [0]);\n exit (1);\n }\n\n srandom (time (0));\n if (howmany == 0)\n howmany = ~0;\n while (howmany > 0)\n {\n conx_sentence ();\n fflush (stdout);\n howmany--;\n if (delay) sleep (delay);\n }\n putchar ('\\n');\n exit (0);\n}\n"] 2) (fset 'conx-emit-c #[(file &optional non-ansi-p) " !  cɱ?! c)eb" [find-file file erase-buffer t buffer-undo-list conx-c-prolog non-ansi-p "\n#if !__STDC__\n" "error! this file requires an ANSI C compiler\n" "#endif\n\n" conx-emit-c-data conx-c-code] 3 "\ Write the current CONX database to a file as C source code. The generated program will have the same effect as M-x conx, except that it runs without emacs. With a prefix argument, write K&R C instead of ANSI C. ANSI is the default because, without a certain ANSI feature, large databases will overflow static limits in most K&R preprocessors." "FWrite C file: \nP"]) (fset 'conx-stats #[nil "!qed| \"ed#" [get-buffer-create "*conx-stats*" mapatoms #[(x) " !? JH\"cc !cc" [boundp x format "%s" 0 " " symbol-name "\n"] 4] conx-words-hashtable sort-numeric-fields -1] 4])