Monday, February 25, 2008

Random Text Generator

Recently I've been fiddling around with a random text generator presented by Paul Graham in his book, ANSI Common Lisp. The premise of the program is that it reads in a text file and determines the frequency with which word pairs appear together. Once the file has been processed, the program can be instructed to generate statements of a given length. I've included 10 samples here for demonstration purposes. Since this is random, there is some grammatical structure but it can be quite lacking in some places. This seems like a good starting point though, and it should be possible to incorporate some grammatical structure in an attempt to improve readability.

Examples (50 words each):
  1. he was visible again to be very ill opinion , they were to miss bingley ; but before the visits which , however , scarcely time , conceited independence which other side and mrs . all the chief of the establishment i believe your kind of my affections and then
  2. to talk of the illustration of composure of a report was very monotonous solemnity as when at rosings was in her . i am thus went to her opinion in vain , and unable to the fire and twenty four miles , and asking your disposition was inquiring . gardiner's
  3. phillips , that the honour of being in their watches , i am sure of their brother's conversation to be rather offended by their premeditated contempt of a momentary embarrassment from much as did , still saw all ; it beyond it was ready to know it is certainly not
  4. bingley tells you build your estimation of pemberley family , by explaining it was going to you how delighted her feelings as flattering with her . i hope you must reflect with the officers had already . elizabeth , for his smiles which elizabeth privately , as they were still
  5. darcy's pleasure , accompanied by such a lessening of her again , her work in her head of the resolution of colonel forster repeat all my father , though not ; and elizabeth felt for teasing colonel forster and she then , would think charlotte took to his pardon .
  6. from him , by the two eldest daughter well . i have been entirely misunderstood before she say on such pleasures ; her to accept it again . darcy's behaviour was not continue the evening , of saying what i shall find it is engaged . on with my humble
  7. 'there , are briefly these it , lizzy , which he always the covies for direction of mrs . mr . he had seen to neglect of so widely different from expecting it over , i believe she had courage enough in a great pleasure , i can alleviate so
  8. her that you ; and vain for themselves . tease him ; and his answer to see her , lizzy , cried her speak ill rewarded by suspense and cheerfulness in safety , added , he was beyond the alarm . he did come themselves for in which he deserves
  9. though a whisper ; and i am perfectly calm ; and dependence on the room ; and soon as to the other family , who seems to take her eyes round the second daughter married ? we were larger . his abilities , receiving them from the staircase , to
  10. in what they were many years ago . bennet , since the unfortunate that he had thrown herself . my situation , and , of herself on every subject , of extravagant in her relation . wickham's character and mrs . wickham's affection . she returned with us ; and

No comments: