{"id":1382,"date":"2010-09-03T18:32:49","date_gmt":"2010-09-04T01:32:49","guid":{"rendered":"https:\/\/mathpirate.net\/log\/?p=1382"},"modified":"2010-09-03T18:38:17","modified_gmt":"2010-09-04T01:38:17","slug":"the-thought-processor","status":"publish","type":"post","link":"https:\/\/mathpirate.net\/log\/2010\/09\/03\/the-thought-processor\/","title":{"rendered":"The Thought Processor"},"content":{"rendered":"<p><em>&gt;That&#8217;s even worse than mine. Ah, he speaks Arabic and I was going to finish any of them, though&#8230;<br \/>\n&gt;Sure, why not? ;) At 3:30 am, the whole cross gender thing again&#8230; and it&#8217;s like from the camera.<br \/>\n&gt;It is. But I&#8217;m not even sure how I left yesterday. I hope threers&#8217; not like some people think I&#8217;m in eternal debt to my headphones&#8230;<br \/>\n&gt;I really need to gnaw on something.<br \/>\n&gt;Ah, well, in that way. It&#8217;s not like this which make me hate him or anything (In fact, he doesn&#8217;t have individual fingers, just a hazard of the car during an accident. Seatbelts are good at getting 0 all the time when I have something and not walking around, you won&#8217;t be able to count at that picture from the left side of the future&#8230;<br \/>\n&gt;Nope, that doesn&#8217;t work, blame sunspots.<br \/>\n&gt;It means something?<br \/>\n&gt;You&#8217;ve never played Castlevania 3??!?!?!?!?!!!!??????????<\/em><\/p>\n<p>Back in college, one of the most entertaining class assignments I had was the one for Dr. Matthews&#8217; 341 course, where we learned about hash tables.\u00c2\u00a0 The assignment involved reading in a text file from Project Gutenberg, running it through a processor, then spitting out a paragraph or two of English-like sentences.\u00c2\u00a0 They weren&#8217;t completely random rearrangements of words.\u00c2\u00a0 On the contrary, they\u00c2\u00a0usually had some form of coherent sentence structure, even though the sentences themselves were often incoherent ((And generally quite entertaining)).<\/p>\n<p>The section at the top of this post is a sample of what this application produces.\u00c2\u00a0 The input was some old chat logs.\u00c2\u00a0 The output is blazing insanity.<\/p>\n<p>This application, and its ability to produce English-like streams of utter nonsense will be at the core of the Echo Chamber.\u00c2\u00a0 Here&#8217;s how it works:<\/p>\n<ol>\n<li>Read in a source of text.<\/li>\n<li>Split the text into words.<\/li>\n<li>For i = 0 to words.length: wordTable[words[i]].Add(words[i\u00c2\u00a0+ 1])<\/li>\n<li>For x = 0 to outputTerms: outputString + currentWord; currentWord = wordTable[currentWord][rand()];<\/li>\n<li>Print outputString.<\/li>\n<\/ol>\n<p>Or something like that.<\/p>\n<p>In other words, when processing the file,\u00c2\u00a0any time you come across a word, add the word that follows it to a list of words that are associated with the first word.\u00c2\u00a0 Then, when producing the output, select a word to get started, then print that word, and randomly select one of the subsequent words to use as the next word, then repeat the print\/select process.<\/p>\n<p>In other words, if you had the input &#8220;A B C B D E B\u00c2\u00a0A F&#8221;, your table would end up something like this:<\/p>\n<p><em>A: {B F}; B: { A C D }; C: { B }; D: { E }; E: { B }; F: null<\/em><\/p>\n<p>And you&#8217;d be able to produce wacky sentences like\u00c2\u00a0 &#8220;A F&#8221; or\u00c2\u00a0&#8220;A B A B A B C B D E B A F&#8221;.<\/p>\n<p>&#8230;<\/p>\n<p>Oh, forget it.\u00c2\u00a0 That&#8217;s too complicated.\u00c2\u00a0 Here&#8217;s a picture instead:<\/p>\n<p><a href=\"https:\/\/mathpirate.net\/log\/wp-content\/uploads\/2010\/09\/DesignSpec.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-1383\" title=\"DesignSpec\" src=\"https:\/\/mathpirate.net\/log\/wp-content\/uploads\/2010\/09\/DesignSpec-183x300.jpg\" alt=\"\" width=\"183\" height=\"300\" srcset=\"https:\/\/mathpirate.net\/log\/wp-content\/uploads\/2010\/09\/DesignSpec-183x300.jpg 183w, https:\/\/mathpirate.net\/log\/wp-content\/uploads\/2010\/09\/DesignSpec-627x1024.jpg 627w, https:\/\/mathpirate.net\/log\/wp-content\/uploads\/2010\/09\/DesignSpec.jpg 984w\" sizes=\"(max-width: 183px) 100vw, 183px\" \/><\/a><\/p>\n<p>The key is that it&#8217;s not completely random gibberish.\u00c2\u00a0 It only contains words that were used in the original source, and more importantly, every pair of words was used in the original source.\u00c2\u00a0 So, if you see a string like &#8220;America the Hedgehog&#8221;, it&#8217;s because it started with &#8220;America&#8221;, randomly chose the word &#8220;the&#8221;, which was in the source due to the line &#8220;<em>America the<\/em> Beautiful&#8221;, then looked up words that followed &#8220;the&#8221; and found &#8220;Hedgehog&#8221;, because &#8220;Sonic <em>the Hedgehog<\/em>&#8221; was somewhere else in the source.\u00c2\u00a0 That&#8217;s what gives it a semi-English sentence\u00c2\u00a0structure, without any parts of speech analysis and without any knowledge about rules of grammar.\u00c2\u00a0 It simply strings together word pairs that a human once used, so verbs follow nouns, articles follow prepositions, and infinitives get split.<\/p>\n<p>In other words, the whole thing is one big iterative &#8220;Before and After&#8221; puzzle from Wheel of Fortune.<\/p>\n<p><em>A bunch of lazy people who want you to feel that lightheaded, anxious feeling again. It makes it uncomfortable. ;)<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&gt;That&#8217;s even worse than mine. Ah, he speaks Arabic and I was going to finish any of them, though&#8230; &gt;Sure, why not? ;) At 3:30 am, the whole cross gender thing again&#8230; and it&#8217;s like from the camera. &gt;It is. But I&#8217;m not even sure how I left yesterday. I hope threers&#8217; not like some [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[161],"tags":[15,16],"_links":{"self":[{"href":"https:\/\/mathpirate.net\/log\/wp-json\/wp\/v2\/posts\/1382"}],"collection":[{"href":"https:\/\/mathpirate.net\/log\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mathpirate.net\/log\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mathpirate.net\/log\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mathpirate.net\/log\/wp-json\/wp\/v2\/comments?post=1382"}],"version-history":[{"count":3,"href":"https:\/\/mathpirate.net\/log\/wp-json\/wp\/v2\/posts\/1382\/revisions"}],"predecessor-version":[{"id":1385,"href":"https:\/\/mathpirate.net\/log\/wp-json\/wp\/v2\/posts\/1382\/revisions\/1385"}],"wp:attachment":[{"href":"https:\/\/mathpirate.net\/log\/wp-json\/wp\/v2\/media?parent=1382"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mathpirate.net\/log\/wp-json\/wp\/v2\/categories?post=1382"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mathpirate.net\/log\/wp-json\/wp\/v2\/tags?post=1382"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}