Dada Poem Generator

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

A digital representation of the Dadaist art technique of pulling random words out of a hat and creating poems. Typically the source in those cases were words cut from print, but for this demonstration I used a list of 100K+ English words.

 

Random Chaos dada gives each word equal odds of appearing, thus producing the most random output. You can see the full list of words here: AllWords.txt

 

Random Order dada uses an analysis of how frequent any given words appears throughout a vary large sample of English literature. With words such as 'the,' 'and,' & 'I' appearing more frequently, the output begins to resemble more closely to natural language, but is still very random. See each words frequency here: AllOdds.txt (Values shown are out of 1, so 0.02 = 2%)

import flash.events.Event;
import flash.events.MouseEvent;
import flash.utils.Timer;
import flash.events.TimerEvent;

var wordCount:int = 7;

slider_sl.addEventListener(Event.CHANGE, sliderChanged);
function sliderChanged(e:Event):void{
	wordCount_ta.text = slider_sl.value.toString();
	wordCount = slider_sl.value;
}

makeDada_btn.addEventListener(MouseEvent.CLICK, makeDadaClick);
function makeDadaClick(e:MouseEvent):void{
	if(chaos_rb.selected == true){
		dadaLand_ta.text = randomChaosDada();
	}
	else if(order_rb.selected == true){
		dadaLand_ta.text = "";
		dadaTimer.reset();
		dadaTimer.repeatCount = wordCount;
		dadaTimer.start();
		//dadaLand_ta.text = randomOrderDada();
	}
	else{}
}

var  wordsLoader:URLLoader  =  new  URLLoader(new  URLRequest("AllWords.txt"));
wordsLoader.addEventListener(Event.COMPLETE,  wordsComplete);

var  oddsLoader:URLLoader  =  new  URLLoader(new  URLRequest("AllOdds.txt"));
oddsLoader.addEventListener(Event.COMPLETE,  oddsComplete);

var allWordsArr:Array = new Array();
var allWordsArrLength:int = 0;

var allOddsArr:Array = new Array();
var allOddsArrLength:int = 0;

function wordsComplete(e:Event):void
{
   //trace(wordsLoader.data);
   
   var txtStr:String = new String(wordsLoader.data);
   allWordsArr = txtStr.split(String.fromCharCode(13));
   //trace(allWordsArr[0]);

   allWordsArrLength = allWordsArr.length-1;
   //trace(allWordsArrLength);
}

function oddsComplete(e:Event):void
{
  // trace(oddsLoader.data);
   
   var txtStr:String = new String(oddsLoader.data);
   allOddsArr = txtStr.split(String.fromCharCode(13));
   //trace(allOddsArr[0]);
   
   allOddsArrLength = allOddsArr.length-1;
   //trace(allOddsArrLength);
}

function arrToNumber(ii:int):Number
{
	return allOddsArr[ii].toString().slice(1,int.MAX_VALUE-1);
}

function arrToString(iii:int):String
{
	return allWordsArr[iii].toString().slice(1,int.MAX_VALUE-1);
}

function randomWord():String
{
	return arrToString(Math.random()*allWordsArrLength);
}

function randomOddsWord():String
{
	var rng:Number;
		rng = Math.random();
		//trace(rng);
	
	var str:String = new String();
	
	for(var i:int=0;i=1){
			str = arrToString(i);
			i = allWordsArrLength;
		}
	}
	return str;
}

function randomChaosDada():String{
	var str:String = new String();
	for (var i:int=0;i