The following is how I adapted the Markov chain generator from Hay Kranen. Thanks to the comments I found below Hay’s post this Markov + Shakespeare version inspired me to figure out the “post-to-Twitter” option.
Anyway, the much cleaner version is up and running. It now allows you to push the results to Twitter although I’m still adjusting this a bit. The code for the page I modified is below. It’s still slower than I’d like but it’ll do for now.
The fact that I can go from a conversation one day to a fairly finished product the next is the piece that amazes me about computers and the Internet. I cannot stress enough that I don’t know how to write PHP. I feel that’s a statement of empowerment. This project took about three hours of work. 95% of that was searching/research and breaking it and then fixing it. Someone who knew what they were doing could probably knock it out in ten minutes.
Now how is this more than just random #ds106 amusement? I think the generator works a little like this example about machine imagined artworks. So there’s a chunk of human constructed meaning from machine assembled pieces. It doesn’t always work but that’s part of why I like having a human layer between generation and Twitter publishing (although I may still automate it when that makes sense time wise). This does generate interesting assignments and juxtaposes them in ways that are similar to the remix assignments idea but with an additional dose of randomness that I like. It also brings older conversations, student products, and links back into the conversation that’s occurring now.
The possibility of the built in @ convention of Twitter has a lot of possibility as well. That element of personalization and specificity could bring people back into the game/course/conversation in ways that reenergize both the participant and the community. There are lots of ways this might be attractive even absent the Markov element. I think there’s value in trying to pull people back into public conversations via methods like this. If participants in a class (MOOC-ish or otherwise) opted in, you could randomly (and judiciously) @ them to engage in conversations around different concepts, posts, products etc. It’d be a balance to avoid being boring and/or spammy but it might be the prompt needed to have a longer term engagement with a course/community.
PHP Markov Chain text generator 1.0.1
Copyright (c) 2008, Hay Kranen <http://www.haykranen.nl/projects/markov/>
License (MIT / X11 license)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Order seems to be the level of chaotic magnitude in the combination from the source. Higher numbers seem to be less disorder.
Length is the number of characters in the returned string.
Text is the path to the text file containing your source data. I did use curl previously to pull directly from a website but found parsing out the html to be problematic.
$order = 6;
$length = 120;
$text = file_get_contents("ds106tweets.txt");
$markov_table = generate_markov_table($text, $order);
$markov = generate_markov_text($length, $markov_table, $order);
if (get_magic_quotes_gpc()) $markov = stripslashes($markov);
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>PHP Markov chain DS106 twitter text generator created by Hay Kranen and butchered by me</title>
<link rel="stylesheet" type="text/css" href="markov.css" />
<h2>Markov Chain DS106 Tweet Text Generator</h2>
<!-- This is where the remixed content gets printed. -->
<div id="quote"><?php echo $markov; ?>
<!-- This is where the content is passed to create the twitter URL. The tweet variable uses urlencode to keep the weird characters from messing everything up. -->
$tweet = urlencode($markov);
$onetwitter = "<a href=\"http://twitter.com/share?url=http%3A%2F%2Ftinyurl.com/m7lpcrz&text=";
$ender = "\">";
echo $onetwitter . $tweet . $ender;