AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Jquery generate random email4/10/2024 Allowing cross-origin use of images and canvas.HTML table advanced features and accessibility.From object to iframe - other embedding technologies.Assessment: Structuring a page of content.review etc.) digital copy of any of my books. And remember, you can also just email me and ask for a free, no-strings-attached (e.g. Most of my novels are available as an immediate free download – simply visit the Fiction page on the main site. Or, if you prefer, you can email me and request a free digital copy. Wanna see what the original novels look like? Why don’t you download from Amazon a copy of Illiterary Fictionor The Other Side of Dreams and find for yourself. As the name perhaps suggests, it combines texts from Kafka and Wittgenstein, deployed using the p5js graphics library – the same I use on the Bookworming Party project. Other Examplesįor a more visual case, take a look at the… “Kafgenstein” example on the homepage of the RiTa library. The time was nine sharp, and he hadn’t cried there either, as it was the wrong place and came back.ĭepending on the texts in question, it’s a matter of finding a balance between randomness and coherence. He’s not willing to try, held back by the unexpected ordeal as he expected, a voice in his hand, and unscrewed the cap. Nobody reads these days, and the roaring New York traffic again begins to pulsate along the short corridor, pushes the heels of his colleagues. What do we need to know about this book, perhaps the man was born. I now use var rm = new RiMarkov(3) which means we have shorter n-grams.Ī rancid smell of abandonment trailing behind him had heard everything, Ahmed thought, terrified that he caught a fleeting glimpse of her heart. Let’s see what happens if we increase randomness (but also the likelihood that the sentences are more incoherent). The main character, Hidetoshi, moves through life too timidly, being in a sense too polite to disrupt the brutality around him. He opens his khaki backpack and squeezes in as many books as he can. And then the human figures pass him by silently, and this is not Paul, and he isn’t the professional reader of this media house. She got up, and Ahmed stood up too, ready to say goodbye. Nobody reads these days, and even those that do, just read the old classics. This is one example of what the code generated with the parameters above: Simple! What this JavaScript Random Text Generator Returns Lines 6 and 7 generate the sentences (5, in this example). In practical terms, longer numbers generate more coherent but less randomized sentences. The number (5) indicates the length of each n-gram. Feel free to check the relevant RiTa documentation page for more. Var rm = new RiMarkov(5) will do our random text generation via so-called Markov chains (or n-grams). Lines 5 to 7 are where the whole process materializes (and where RiTa comes into play). Obviously, in such a case there’s no need for the text file to begin with let text = ` Combining Sentences and Getting Results If you’re working with something similar online, something like this would do the trick: var myText = getMyText() Then, as you notice on line 6, the variable text (the two chapters) is neatly passed as a parameter. The textCombo.txt begins with let text = ` followed by the entire text (i.e. It’s a little trick to avoid the cross-origin request (CORS) issue when running scripts locally. If you know JavaScript, you must feel confused by this – why am I loading as a script src a. Line 3 loads the text file containing the first two chapters of my novel. About… Well, 10 is a nice round number, right? It shows 11 lines – but hey, remove the html tags, and it’s 10. However, this is only possible because of the excellent RiTa library, which is a must for anyone coding with text. Why write a text with a pen, when you can write it with a JavaScript random text generator A JavaScript Random Text Generator: the Code The difference is, this time I decided to i) code it in JavaScript (rather than Java) ii) use the first two chapters of two of my novels, Illiterary Fiction and The Other Side of Dreams to generate the results. If this sounds somewhat familiar, it’s very similar to my Ghostwriter Android app. This little program – in only 10 lines of code – combines text from different sources and returns a set of randomized sentences. In this post, I decided to make something a bit mad, so I came up with a very simple (but very funny!) JavaScript random text generator.īut this isn’t just any random… random text generator like, say, my random quote generator. Just to name two examples, see my rhyming anapest generator or my Gothic analyzer program. Virtually all of my coding revolves around text, one way or another.
0 Comments
Read More
Leave a Reply. |