xxxxxxxxxx
58
var q = "will you move to halifax with me?";
var rq = new RiString(q);
var lexicon
function setup() {
createCanvas(400, 400);
lexicon = new RiLexicon();
button1 = createButton("yes! a million times yes!")
button2 = createButton("that makes me want to end things...")
x = width/2
y= height/2
}
function draw() {
background(220);
fill(230, 69, 70)
ellipse (x, y, 20, 20)
x = x + random(-1, 1);
y = y + random (-1, 1);
fill(50);
text(rq, 10, 10, 70, 80); // Text wraps within text box
button1.mousePressed(thankgod)
button2.mousePressed(processRita);
}
function processRita(){
var words = rq.words();
var pos = rq.pos();
console.log(words);
console.log(pos);
//loop over words
var output = '';
for (var i = 0; i < words.length; i++) {
//replaces halifax with new spot
if (pos[i] === "nn"){
output += lexicon.randomWord('nn');
} else {
output += words[i];
}
output += " ";
createP("ok then, so " + output);
}
}
function thankgod(){
createP("You are my lobster!")
}