Marko.Wpm (WordPerfect 5.1) by Randy Bohn Marko.Wpm is Public Domain and freely distributable! Description: Marko uses a technique known as Markov Chaining to generate new text from the old. This technique is to take two words and then predict statistically what word will follow. Then randomly select one of those words and add it to the first two words. Then keep doing that as long as you like. For example, if I use some anthology of english literature to generate my statistical predictor, and start with "Once upon", the most likely next word will be "a". So I have "Once upon a" and the chances are nine out of ten times the phrase "upon a" will be followed by "time", but the tenth time by "midnight" (as in "midnight dreary"). So each iteration adds one word to my new text. Marko.wpm includes a workable random number generator that you can use in other WordPerfect macros. Installation: Put Marko.wpm in your WordPerfect Macros directory. If you don't know where this is, use Shift-F1,L to get to the Location of Files screen, and write down the second directory listed (Keyboard/Macro files). The default is probably C:\WP51 or something similar. If you cannot put the macro here (you are on a network with restricted rights) you can still use the macro, just remember where you have it stored. Using Marko: First thing to do is create the Statistical Predictor (sounds impressive and difficult, doesn't it?) All you have to do is collect all the documents you can find into one WordPerfect file. Also, this macro doesn't like hyphens, so try to strip out all hyphens (search/replace them (Alt-F2) with spaces). Get the hard hyphens as well (Home-Hyphen). Save this file (I like to call it StatPred.doc, but you might like to use Marko.doc). To run the macro, put your Predictor in one document, the use Shift-F3 to switch to the other document (which should be blank). 1 Marko.wpm Documentation RS Bohn Using: (cont) Now you must enter a starting phrase. It can be more than two words, just make sure to end with two words that can be found together in your Predictor document. I used "Marko.wpm is a " for the sample following. Be sure to leave ONE space at the end of your phrase. After you have your phrase, press Alt-F10, then type in MARKO and press to start the macro. If you weren't able to use the WordPerfect Macros directory (in Installation above) type in the full path to the directory where you have the macro stored (C:\FILES\MARKO.WPM for example). As the macro runs it will switch back and forth between documents as it selects new words and adds them to the new text. I like to split the screen (Ctrl-F3,W,10) and watch the macro run. You may press Cancel (F1) at any time to stop and read. If you are in the Predictor document, just press Shift-F3 to go back to your new text. You can continue by simply re-starting the macro. Sample: I used my wife's senior english papers and other writings to create the Statistical Predictor for this sample. The starting phrase was "Marko.wpm is a ". Marko.wpm is a medical treatment that has existed for centuries. The Chinese believe that Hamlet is only pretending to be reconciled with Ophelia. But he did, and right across my path by the presence of fire (sun, moon, or hearth fire), the creation recorded in the Way to Rainy Mountain, by Momaday, one of his horse saves the lives of his horse saves the lives of his or her duties and privileges on earth. Hmm, pretty cryptic. The content depends entirely on the sources you use for your Statistical Predictor, and the larger it is the better it will work. I hope you enjoy using this macro. The following gets technical, and is not required reading: Theory and operation: In my first attempt to do Markov Chaining I considered creating a list of word pairs, followed by a probability rating for the third word. it was, a, 5 it was, the, 4 it was, not, 1 But then I realized I didn't need the rating, I could just list triplets and pick one at random: it was a it was the it was a it was a it was not 2 Marko.wpm Documentation RS Bohn it was a it was the it was the it was a it was the It was pretty trivial to write a macro to split a document into triplets, and another to pick one at random (ok, that was a bit harder). But this was slow and a disk space hog. This paragraph would be rendered It was pretty was pretty trivial pretty trivial to trivial to write etc. I also lost all formatting doing it this way. So I thought about it for awhile, and realized that I could just search through a complete document for my word pairs, then flip a coin to decide if that was the word I wanted. If not, I would search for the next occurrence of my pair and flip again. At either end of the document, I just move one page away, then reverse the search direction. I turn the display off at critical parts of execution to speed up the macro, but I do leave it on for others so you can watch the macro work. The random number generator is the last subroutine in the file. You may save it as Rand.wpm and {NEST} it to use it. It uses {VARIABLE}seed~ to generate new random numbers. -Randy Bohn 3 Oct 1992 WordPerfect is a registered trademark of WordPerfect Corporation. 3