Project Narrative:
Wordistortion is an exercise in literary recombination and procedural text generation. It seeks to explore the extent to which a literary work and the voice of its author can be recombined with itself again and again until it becomes virtually unrecognizable, yet somehow also disturbingly familiar.
Video/Image/Sound/Code Documentation:
Installation Scenario:
There would be a screen where the program displays and updates its body of text indefinitely, once every thirty seconds. A single button would be available for viewers to press in order to restart the program afresh on the original text, which it would then proceed to recreate/distort again.
The Language of Praise:
Monday, May 30, 2016
Thursday, May 26, 2016
Documentation 1: Prototype
Initially I wanted to create a Twitter bot that would read several posts in either the #feelthebern, #makeamericagreatagain, or the #imwithher tag (I hadn't decided which one), create a Markov transition matrix from the tweets, and generate a new tweet using the matrix, repeating the process every few minutes, hopefully creating a somewhat plausible character in the style of Mark V. Shaney. However, my efforts to make any of the Twitter addons that I found (ofxTwitter, ofxtwitcurl, ofxOAuth) work for me proved fruitless. I kept getting errors that I couldn't find fixes to with my limited knowledge. Stackoverflow and the openframeworks forums were unhelpful as well - everything about Twitter on the OF forums was at least a year or two old. So I decided to opt for a simpler concept that I still felt would have interesting results.
My new concept was that my program would take a large text, generate a Markov matrix by analyzing it, create a new text, generate a new matrix by analyzing the new text, create a new text from the new matrix, and so on. The text I decided on was Donna Haraway's A Cyborg Manifesto. I found the full text online, cleaned it up (since it had a bunch of whitespace, page numbers and spelling errors), and saved it.
Using your conceptual research journal entry for context, describe the ofxaddon that will be incorporated in your final project.
I am using ofxMarkovChain. I initially had problems implementing it, but I got it to work by looking at this post and changing the name of the check() function to mycheck() instead. After that, I was able to make its two examples work.
I had some trouble writing to a text file, though. I tried it both with ofFile and with ofstream, but no matter what, for some reason it's writing Chinese characters instead of the string I specified. Even using information from the official C++ docs, it's still not working. Stackoverflow says that it's related to the fact that the string's binary values are being recorded and used to locate an address in memory, but I haven't found a fix for it yet, as of May 30, 6:15PM. It seems to me that I'm doing things the way that is being recommended, but for some reason it's not working the same way. Typical programmer troubles, I suppose.
How does the addon support your conceptual experimentation?
The addon is a simple framework through which I can implement a previously created Markov transition matrix.
How does the addon work? What other research/libraries support it?
The addon reads a text file formatted in the style of a square matrix. Each row and column represents one possible state, and each value in each row represents the probability of transitioning to the corresponding state. From there, the addon can generate a sequence of states that can be used to draw to the screen. It uses ofRandom to randomly determine the next state.
It's based on the theory of Markov chains, which are random processes that transition from one state to another based on probabilities that depend solely on the current state. So the probability of, say, state B appearing in a Markov chain is dependent on the previous state and the likelihood of it transitioning to state B. With a transition matrix like:
So say you're in state A, you have a large likelihood of transitioning to state B (60%), and vice versa (50%). So whenever state B and A appear, it's very possible that they will alternate back and forth. But if state C appears, it's likely that it will simply stay in state C instead of transitioning to A or B, because the probability of it staying in state C is so high (70%).
Markov chains are named after Andrey Markov
Document a first integration of the addon in your app development.
At this stage, I still haven't gotten the app to write properly to the file, but it's definitely writing. So I implemented the Markov addon in order to generate the output according to a transition matrix that was provided with one of the examples.
The transition matrix only has 5 states at this point, so it'll generate only the letters a through e.
So I have my update() function calling the ofxMarkovChain's update() and getState(), which generates a new state and then returns that state, respectively.
From there I have a switch statement that matches each state to a letter. I then have the program write the generated letters to the file and also print them to the console. Hooray, it works!
And the written files look like this:
You can tell that they're different, so that goes to demonstrate again that the Markov chains are working. But the original problem - why the written file is in Chinese of all things - is still not solved.
Searching "c++ writing chinese to file" led me here, but I don't think the problem is the same as mine. This thread also wasn't that helpful. This post seems more promising, though.
I tried writing to a text file in a non-openframeworks project, and it worked!
So it seems that the problem lies with something in openframeworks, not with my computer or with xcode. Hmm.
To create the transition matrix, I'm using a vector of vectors of floats - the same format as the matrix used in ofxMarkovChain. I will also be using a separate vector to store the characters that correspond to each state.
References:
Markov Models for Text Analysis - http://www.stat.purdue.edu/~mdw/CSOI/MarkovLab.html
A working Markov text generator - http://projects.haykranen.nl/markov/demo/
The source for the text generator - https://github.com/hay/markov
Markov Chain text generator - https://golang.org/doc/codewalk/markov/
Creating a Markov Twitter bot - http://sts10.github.io/blog/2014/12/23/guide-create-markov-twitter-bot/
https://www.cs.umd.edu/class/winter2012/cmsc389C/Projects/P1/P1.html
Stackoverflow Markov advice - http://stackoverflow.com/questions/12065503/predicting-next-char-in-random-text-generation-based-on-some-input-file
Stackoverflow checking for an element in a vector - http://stackoverflow.com/questions/6277646/in-c-check-if-stdvectorstring-contains-a-certain-value
Stackoverflow iterator help - http://stackoverflow.com/questions/15099707/how-to-get-position-of-a-certain-element-in-strings-vector-to-use-it-as-an-inde
Addons:
https://github.com/elaye/ofxMarkovChain
https://github.com/andrebaltaz/ofxHMM
Artists:
Bruce Ellis and Rob Pike - Mark V. Shaney
My new concept was that my program would take a large text, generate a Markov matrix by analyzing it, create a new text, generate a new matrix by analyzing the new text, create a new text from the new matrix, and so on. The text I decided on was Donna Haraway's A Cyborg Manifesto. I found the full text online, cleaned it up (since it had a bunch of whitespace, page numbers and spelling errors), and saved it.
Using your conceptual research journal entry for context, describe the ofxaddon that will be incorporated in your final project.
I am using ofxMarkovChain. I initially had problems implementing it, but I got it to work by looking at this post and changing the name of the check() function to mycheck() instead. After that, I was able to make its two examples work.
I had some trouble writing to a text file, though. I tried it both with ofFile and with ofstream, but no matter what, for some reason it's writing Chinese characters instead of the string I specified. Even using information from the official C++ docs, it's still not working. Stackoverflow says that it's related to the fact that the string's binary values are being recorded and used to locate an address in memory, but I haven't found a fix for it yet, as of May 30, 6:15PM. It seems to me that I'm doing things the way that is being recommended, but for some reason it's not working the same way. Typical programmer troubles, I suppose.
This doesn't work either.
How does the addon support your conceptual experimentation?
The addon is a simple framework through which I can implement a previously created Markov transition matrix.
How does the addon work? What other research/libraries support it?
The addon reads a text file formatted in the style of a square matrix. Each row and column represents one possible state, and each value in each row represents the probability of transitioning to the corresponding state. From there, the addon can generate a sequence of states that can be used to draw to the screen. It uses ofRandom to randomly determine the next state.
It's based on the theory of Markov chains, which are random processes that transition from one state to another based on probabilities that depend solely on the current state. So the probability of, say, state B appearing in a Markov chain is dependent on the previous state and the likelihood of it transitioning to state B. With a transition matrix like:
State | Probability of trans. to A | Probability of trans. to B | Probability of trans. to C |
---|---|---|---|
A | 10% | 60% | 30% |
B | 50% | 30% | 20% |
C | 20% | 10% | 70% |
So say you're in state A, you have a large likelihood of transitioning to state B (60%), and vice versa (50%). So whenever state B and A appear, it's very possible that they will alternate back and forth. But if state C appears, it's likely that it will simply stay in state C instead of transitioning to A or B, because the probability of it staying in state C is so high (70%).
Markov chains are named after Andrey Markov
Document a first integration of the addon in your app development.
At this stage, I still haven't gotten the app to write properly to the file, but it's definitely writing. So I implemented the Markov addon in order to generate the output according to a transition matrix that was provided with one of the examples.
The transition matrix only has 5 states at this point, so it'll generate only the letters a through e.
So I have my update() function calling the ofxMarkovChain's update() and getState(), which generates a new state and then returns that state, respectively.
From there I have a switch statement that matches each state to a letter. I then have the program write the generated letters to the file and also print them to the console. Hooray, it works!
And the written files look like this:
You can tell that they're different, so that goes to demonstrate again that the Markov chains are working. But the original problem - why the written file is in Chinese of all things - is still not solved.
Searching "c++ writing chinese to file" led me here, but I don't think the problem is the same as mine. This thread also wasn't that helpful. This post seems more promising, though.
I tried writing to a text file in a non-openframeworks project, and it worked!
So it seems that the problem lies with something in openframeworks, not with my computer or with xcode. Hmm.
To create the transition matrix, I'm using a vector of vectors of floats - the same format as the matrix used in ofxMarkovChain. I will also be using a separate vector to store the characters that correspond to each state.
References:
Markov Models for Text Analysis - http://www.stat.purdue.edu/~mdw/CSOI/MarkovLab.html
A working Markov text generator - http://projects.haykranen.nl/markov/demo/
The source for the text generator - https://github.com/hay/markov
Markov Chain text generator - https://golang.org/doc/codewalk/markov/
Creating a Markov Twitter bot - http://sts10.github.io/blog/2014/12/23/guide-create-markov-twitter-bot/
https://www.cs.umd.edu/class/winter2012/cmsc389C/Projects/P1/P1.html
Stackoverflow Markov advice - http://stackoverflow.com/questions/12065503/predicting-next-char-in-random-text-generation-based-on-some-input-file
Stackoverflow checking for an element in a vector - http://stackoverflow.com/questions/6277646/in-c-check-if-stdvectorstring-contains-a-certain-value
Stackoverflow iterator help - http://stackoverflow.com/questions/15099707/how-to-get-position-of-a-certain-element-in-strings-vector-to-use-it-as-an-inde
Addons:
https://github.com/elaye/ofxMarkovChain
https://github.com/andrebaltaz/ofxHMM
Artists:
Bruce Ellis and Rob Pike - Mark V. Shaney
Subscribe to:
Posts (Atom)