home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / editors / markv10.arj / MARKV.DOC next >
Text File  |  1991-05-14  |  10KB  |  245 lines

  1.  
  2.                         Mark V. Shaney V1.0
  3.                    a probabilistic text generator
  4.                        (c) 1991 Stefan Strack
  5.                          stst@cs.albany.edu
  6.                        ss9557@albnyvms.bitnet
  7.  
  8.  
  9. You may copy this program freely, provided you leave the program and this
  10. documentation unchanged. You may not charge more than the cost of the media
  11. for its distribution. I disclaim all liabilities for any damages or loss of
  12. data incurred by using this program. Comments are appreciated.
  13.  
  14.  
  15. --------------------
  16. Credits
  17.  
  18. Mark V. Shaney featured in the "Computer Recreations" column by A.K.Dewdney
  19. in Scientific American. The original program (for a main-frame, I believe)
  20. was written by Bruce Ellis based on an idea by Don P. Mitchell. Dewdney tells
  21. the amusing story of a riot on net.singles when Mark V. Shaney's ramblings
  22. were unleashed.
  23.  
  24.  
  25. --------------------
  26. Who is Mark V. Shaney?
  27.  
  28. Mark V. Shaney produces a confused imitation of style and contents of a piece 
  29. of writing. Mark reads the original text and builds a "word probability 
  30. table" that reflects the probability of a word following a sequence of words.  
  31. In output mode, Mark will generate random text weighed by the probabilities
  32. in this table (a so-called Markov chain, hence Mark's name). Since Mark
  33. considers punctuation as part of the word, he is likely to produce
  34. grammatical sentences, albeit a caricature of the original text. Mark V.
  35. Shaney is in the same league with the famous "ELIZA" and "Racter" programs,
  36. and shows that you don't need AI for "almost human" writing. This
  37. implementation of Mark V. Shaney allows you to vary the "randomness" of the
  38. text output and supports huge probability tables in expanded memory or on
  39. disk.
  40.  
  41.  
  42. --------------------
  43. What the program runs on
  44.  
  45. Mark V. Shaney is not a speed demon. While you could run the program on a
  46. dual-floppy XT, you probably would not want to. A 640K AT system with a hard
  47. disk is recommended as the minimum configuration. If you have memory above
  48. 640K and an expanded memory driver installed, Mark V. Shaney will be able to
  49. make use of it.
  50.  
  51.  
  52. --------------------
  53. Using the program
  54.  
  55. Type MARKV to start Mark V. Shaney. The menu on the bottom line of the screen
  56. gives you the following choices invoked by pressing their first letter:
  57.  
  58.         Read text
  59.  
  60.         The program will prompt you for a text file to read, building a word
  61.         probability table as it goes along. Text files should not contain
  62.         control or formatting characters other than tabs and carriage
  63.         return/line feeds. Reading is very slow and can take several minutes
  64.         for large files. Speed can be improved by increasing the number of
  65.         DOS buffers in CONFIG.SYS. The bottle neck seems to be the CPU, which
  66.         means you won't gain much from reading from a RAM drive.  You can
  67.         repeat this command to build a table from several text files. Reading
  68.         will stop if you press any key.
  69.  
  70.  
  71.         Generate text
  72.  
  73.         After you created a working probability table by either reading text 
  74.         files or loading a saved table, "Generate text" will start the
  75.         probabilistic text generator. You are prompted for a file to append
  76.         the text output to. If you press <Return>, output will go to the
  77.         screen. Mark's ramblings will word-wrap automatically; no other
  78.         formatting is done. The output will stop, when (a) Mark comes across
  79.         a word that is the last word in one of the input texts, or (b) you
  80.         press <Escape> after pausing output. You can pause output by pressing
  81.         any key.
  82.  
  83.  
  84.         Load table
  85.  
  86.         Once a probability table has been build, it can be saved to a file
  87.         (see Save table). "Load table" prompts you for a table to be
  88.         retrieved from disk. This is much faster than re-creating the table
  89.         from scratch by reading the original text files again. The down-side
  90.         is that saved tables are huge, about 9 times the size of the input
  91.         text.
  92.  
  93.  
  94.         Save table
  95.  
  96.         Saves the probability table to disk.
  97.  
  98.  
  99.         Quit
  100.  
  101.         Exits the program.
  102.  
  103.  
  104. --------------------
  105. Command line options
  106.  
  107.         MARKV [-e/-m/-d[n:path]] [-g#] [-s#]
  108.  
  109.                 -e              use EMS (default)
  110.                 -m              use conventional memory
  111.                 -d[n:path]      use disk
  112.                 -g#             set word grain to # (default 2)
  113.                 -s#             set random number seed to #
  114.  
  115.         These options are explained in the next sections. Mark will also
  116.         accept the slash (/) character instead of the hyphen, or simply the
  117.         option letter by itself.
  118.  
  119.  
  120. --------------------
  121. The word grain option
  122.  
  123. In the original description of Mark V. Shaney's algorithm, the word grain is
  124. 2. This means that the program breaks down an input text into pairs of words,
  125. and calculates the probability of a third word following a given pair of
  126. words. The probability table then looks like this:
  127.  
  128.      Word grain 2
  129.  
  130.                  \Next Word
  131.         Word seq  \   A       B       C        D       ..
  132.         ---------------------------------------------------
  133.             AB     |  0.0     0.02    0.08     0.15    ..
  134.             BC     |  0.0     0.0     0.0      0.02    ..
  135.             CD     |  0.02    0.22    0.0      0.0     ..
  136.             DE     |  0.1     0.06    0.03     0.0     ..
  137.             ..     |  ..      ..      ..       ..      ..
  138.  
  139. MARKV.EXE allows you to choose the word grain, i.e. the number of words that
  140. make up a word sequence, with the command line option -g#.
  141.  
  142. E.g.:   MARKV -G3
  143.  
  144. After reading a text, this results in the following probability table:
  145.  
  146.      Word grain 3
  147.  
  148.                  \Next Word
  149.         Word seq  \   A       B       C       D       ..
  150.         --------------------------------------------------
  151.             ABC    |  0.01    0.0     0.0     0.02    ..
  152.             BCD    |  0.0     0.0     0.0     0.0     ..
  153.             CDE    |  0.04    0.01    0.0     0.0     ..
  154.             DEF    |  0.02    0.0     0.08    0.0     ..
  155.             ..     |  ..      ..      ..      ..      ..
  156.  
  157. Similarly, -g1 breaks down an input text into word sequences of length 1. The 
  158. word grain can be any number greater than or equal 1. Word sequences of 
  159. longer than 3 are not very interesting, since Mark V. Shaney will essentially
  160. re-create the original text when in output mode.
  161.  
  162. In general, large values for the word grain produce low variability in
  163. the output text. Also, large input texts tend to result in more diverse
  164. output. You can create a sufficiently variable output from a short text
  165. sample by setting the word grain to 1.
  166.  
  167. Table creation speed is largely independent of the word grain, whereas table
  168. size increases with word grain. Text playback depends on the structure of the
  169. current probability table, but is independent of the value of the word grain
  170. parameter with which the program was invoked. This is useful to know if you
  171. are loading a previously created table from disk.
  172.  
  173.  
  174. --------------------
  175. Storage options
  176.  
  177. MARKV.EXE is able to use EMS memory or a disk for storing huge probability
  178. tables. The location of the working probability table can be specified by one
  179. of the following options:
  180.  
  181. MARKV -E
  182.  
  183. This tells Mark to use expanded memory if available; this is also the
  184. default. If expanded memory is not available, the table will reside in
  185. conventional memory. 1 MB of EMS allows you to process about 110K of text
  186. input.
  187.  
  188. MARKV -M
  189.  
  190. Mark will keep the table in conventional memory along with the program code.  
  191. On a 640K machine, this gives you room for processing approx. 40K of original
  192. text.
  193.  
  194. MARKV -D[Drive:Path]
  195.  
  196. Mark uses the disk to store the working probability table. The optional 
  197. Drive:Path specifies were the temporary file is to be stored. This is the 
  198. slowest option, but you can speed up processing greatly by specifying a RAM
  199. drive. The amount of input text that can be processed is limited by the
  200. available disk space.  Example: MARKV -DE: will set up disk storage on drive
  201. E:.
  202.  
  203.  
  204. --------------------
  205. The random number seed option
  206.  
  207. Mark will initialize the random number generator by reading the system time
  208. at program start. This makes sure that the random output is different every
  209. time you use the same probability table. In case you see some particularly
  210. interesting output scrolling off screen, you may wish to restart the program
  211. under identical conditions. For this purpose, Mark displays the number that
  212. initialized the random number generator when you exit the program. You can
  213. then provide this seed on the command line as in
  214.  
  215. MARKV -S12345
  216.  
  217. to re-create a previous run.
  218.  
  219.  
  220. --------------------
  221. Sources of text
  222.  
  223. The larger the input text, the more diversified will be Mark V. Shaney's
  224. ramblings. With a word grain of 2, a 15 to 30K text will produce a varied,
  225. but still comprehensible output. Good choices for input text are: personal
  226. letters, text books, childrens' books, simple narratives, poems (anything
  227. made up of simple, short sentences). Poor choices are texts containing
  228. incomplete or complicated sentences with special terminology (technical
  229. writing, program documentation (this one's especially poor :-) ), etc ..).
  230. The Old Testament provides excellent material downloadable from many
  231. anonymous FTP-sites; try e.g. the Song of Solomon. (Please don't take
  232. offense; this suggestion comes out of deep respect for the Bible)
  233.  
  234.  
  235. --------------------
  236. Implementation
  237.  
  238. The source for Mark V. Shaney is ca. 400 lines of code written in PDC Prolog
  239. V3.21. Word probability tables are stored in external databases. The
  240. dictionary (list of unique words) and frequency table are hashed to speed up
  241. table generation, and cross-referenced for text output in constant time.
  242. I designed this program for flexibility (i.e. adjustable word grain) and
  243. speedy output generation. The trade-offs are slow text scanning and large
  244. memory/disk space requirements.
  245.