LICENSE | ||
MarkovWordGen.java | ||
README.md | ||
WordNode.java |
MarkovTextGen
Text generation using markov chains. It is worth noting that it will plagiarize in some situations, and for any nGram (unigram, bigram, etc.) any consecutive group of n+1 tokens will be found in the original training data.
Example output based on Edgar Allan Poe stories:
This example is from a bigram model, and was trained from The Cask of Amontillado, The Tell Tale Heart, and The Raven.
The thousand injuries of Fortunato I had been sitting, and grated it upon the vaults. We are below the river‘s bed. The drops of moisture trickle among the bones. Come, we will go back; you will be ill, and I cannot be responsible. Besides, there is Luchesi ——” “He is an ignoramus,” interrupted my friend, not yet recovered from his astonishment. “True,” I replied; “and I was silly enough to pay the full Amontillado price without consulting you in the country. I took my arm, and we proceeded. “These vaults,” he said, “are extensive.” “The Montresors,” I replied, “were a great and numerous family.” “I forget your arms.” “A huge human foot d‘or, in a field azure; the foot of the soul when overcharged with awe. I knew that he had been drinking much. The man wore motley. He had never wronged me. He had never given me insult. For his gold I had no desire. I think it was impossible to say how first the idea entered my brain; but once conceived, it haunted me day and night. Object there was none. Passion there was none. I loved the old man’s face or person: for I had been aroused; information had been lying awake ever since the first slight noise, when he ventured upon insult I vowed revenge. You, who so well know the nature of my friend was unsteady, and the old man, I mentioned, was absent in the matter. You were not to stir from the Nightly shore— Tell me what thy lordly name is on the floor to and fro with heavy strides, as if his soul in that one word he did not enable us to see. “Proceed,” I said; “yes, yes.” “You? Impossible! A mason?” “A mason,” I replied. “A sign,” he said. The wine sparkled in his face, and he not even to dream before; But the fact is I was so pleased to see him that I might not disturb the old man, indeed, to suspect that every night, just at twelve, I looked at him in surprise. He repeated the movement — a very profound old man, and thus rid myself of the heart and held it there many minutes. There was no pulsation. He was too much astounded to resist. Withdrawing the key I stepped back from the throat of the men — but I found the eye always closed; and so I knew that he had passed through a range of low arches, descended, passed on, and descending again, arrived at a deep crypt, in which the foulness of the senses? — now, I say, louder every moment! — do you mark me well? I have told you that I gave utterance to a threat. At length I would be heard by a neighbor during the supreme madness of the Medoc.” I broke and reached him a flaçon of De Grâve. He emptied it at the palazzo — the sound would be avenged; this was a low, dull, quick sound, such as a token of that lie thy soul hath spoken! Leave my loneliness unbroken!—quit the bust above his chamber door, With such name as “Nevermore.” But the silence was unbroken, and the eleventh; there remained but a single thin ray fell upon me, my blood ran cold; and so by degrees — very gradually — I surpassed them in volume and in the bed suddenly, as if his soul in that one word he did outpour. Nothing farther then he uttered—not a feather then he fluttered— Till I scarcely more than muttered “Other friends have flown before.” Then the bird said “Nevermore.” Startled at the palazzo — the sound would be avenged; this was a quack, but in the country. I took my arm, and we proceeded. “These vaults,” he said, at last. “Come,” I said, with decision, “we will go back ere it is and nothing more. Then this ebony bird beguiling my sad fancy into smiling, Straight I wheeled a cushioned seat in front of bird, and bust and door; Then, upon the velvet sinking, I betook myself to linking Fancy unto fancy, thinking what this ominous bird of yore Meant in croaking “Nevermore.” This I whispered, and an echo murmured back the word, “Lenore!”— Merely this and nothing more.” Ah, distinctly I remember it was the low stifled sound that arises from the depth of the colossal supports of the soul when overcharged with awe. I knew that he could not see the opening so far that I thought I should not return until the morning, and had given them explicit orders not to stir from the throat of the catacombs, and was about dusk, one evening during the supreme madness of the eye forever. Now this is the Amontillado. But is it not getting late? Will not they be awaiting us at the idea; and perhaps he heard me; for he had reached the extremity of the carnival!” “I have my doubts.” “How?” said he. “Amontillado? A pipe? Impossible! And in the country. I took my visitors all over the mason-work, threw a few feeble rays upon the sculptured bust above his chamber door— Bird or beast upon the vaults. We are below the river‘s bed. The drops of moisture trickle among the pile of bones of which I had no intention of alarming you unnecessarily — but I could scarcely contain my feelings of triumph. To think that there I was, opening the door, little by little, and he did outpour. Nothing farther then he fluttered— Till I scarcely breathed. I held the lantern motionless. I tried how steadily I could see nothing else of the catacombs of Paris.