Published
Edited
Apr 21, 2021
4 forks
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
stanzaNumber
Insert cell
chosenPoem.stanzas.length
Insert cell
gibList.length
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
prepPoem = function() {
gibDict.clear();
for (let i = 0; i < chosenPoem.replace.length; i++) {
//gibDict.set(generateGibberish(chosenPoem.replace[i], ""));
gibDict.set(chosenPoem.replace[i], {
gibberishWord: generateGibberish(chosenPoem.replace[i]),
userSynonym: ""
});
gibList[i] = gibDict.get(chosenPoem.replace[i]).gibberishWord;
}
mutable preppedPoem = makeNewPoem();

mutable consoleLog = gibDict;

mutable titleDisplay = `<h3><i>${chosenPoem.name}</i></h3>`;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
displayText = function() {
// mutable stanzaNumber ++;
// DEBUGGING console.log("displayText");
//for every line
console.log(preppedPoem[stanzaNumber]);
//mutable txt += "<br>" + preppedPoem[stanzaNumber];

if (bool == true) {
if (gibList.length > 0) {
//if there are still words to replace

let oldStanza = cleanWordArrays(
chosenPoem.stanzas[stanzaNumber].split(/[ \n]/)
); //array of words in old stanza

let newStanza = cleanWordArrays(preppedPoem[stanzaNumber].split(/[ \n]/));

for (let f = 0; f < gibList.length; f++) {
let index = newStanza.indexOf(gibList[f]);
//for every Gibberish left to replace...until match found
if (index != -1) {
//displayPoem(index, stanz);
//display2.innerText = "‘" + gibList[f] + "’ means:";

let oldWord = oldStanza[index];

//USER INPUT//
if (textInput !== "") {
let text = textInput;
mutable synInput = text;
// this will add the definition to the dictionary:
gibDict.set(oldWord, {
gibberishWord: gibList[f],
userSynonym: text.toLowerCase()
});
gibList.splice(f, 1); //remove defined gibberish from replacementGibberish
//for NEXT GIBBERISH WORD
} //end of user input
//mutable replacementGibberish = gibList; //CANT GET GIBBERISH LIST TO SHRINK
//displayPoem();
break;
} // end of if word is in Stanza
} // done cycling through gibList
}
displayPoem();
}
}

//pause a couple second
//button appears on screen with "Write a poem?" on it
//-->pressing the button causes the current display to fade out and me replaced by the new poem appearring word by shifting word on screen
Insert cell
mutable bool = true
Insert cell
function displayPoem(/*ind, stanza*/) {
let editTxt = "";
let stanz = stanzaNumber;
let gList = gibList;

if (
intersect(
gList,
cleanWordArrays(preppedPoem[stanzaNumber].split(/[ \n]/))
) == 0
) {
if (chosenPoem.stanzas[stanzaNumber + 1] == `${"\n"}`) {
//stanz = +2;
stanz += 2;
//editTxt += "<br>"; //+ preppedPoem[stanzaNumber] + "<br>";
} else {
stanz++;
//stanz++;
}
}

let oldStanza = cleanWordArrays(chosenPoem.stanzas[stanz].split(/[ \n]/)); //array of words in old stanza

let newStanza = cleanWordArrays(preppedPoem[stanz].split(/[ \n]/));

let poem = preppedPoem[stanz].split(/[ \n]/);

if (gList.length > 0) {
for (let f = 0; f < gibList.length; f++) {
let index = newStanza.indexOf(gibList[f]);
if (index != -1) {
display2.innerText = "‘" + gibList[f] + "’ means:";
poem[index] = "<mark>" + poem[index] + "</mark>";
// let newPoem = RiTa.untokenize(poem);
break;
}
}
} else if (stanz < preppedPoem.length - 1) {
display2.innerText = "Press 'Continue the Poem'";
display3.innerText = "Continue the Poem";
} else {
display2.innerText = "Press 'Write New Poem'";
display3.innerText = "Done.";
//poem = cleanWordArrays(poem);
//mutable bool = false;
}

for (let i = 1; i < stanz; i++) {
editTxt += preppedPoem[i] + "<br>";
}
editTxt = editTxt.replaceAll("<mark>", "");
editTxt = editTxt.replaceAll("</mark>", "");

editTxt += poem.join(" ") + "<br>";
mutable txt = editTxt;
mutable stanzaNumber = stanz;
}
Insert cell
function makeNewPoem() {
let string = [];
for (let i = 0; i < chosenPoem.stanzas.length; i++) {
string[i] = chosenPoem.stanzas[i];
for (let j = 0; j < chosenPoem.replace.length; j++) {
//for every word to replace
string[i] = becomeGibberish(
string[i].split(/[ \n]/),
chosenPoem.replace[j],
gibDict.get(chosenPoem.replace[j]).gibberishWord
);
}
}
mutable stanzaNumber = 1;
//mutable gibList = [];
display1.innerText = "";
display2.innerText = "Click 'Gibberfy'";
//display5.innerText = "Poem Prepared.";
return string; //turn poem array into string
}
Insert cell
Insert cell
function cleanWordArrays(wordArray) {
for (let i = 0; i < wordArray.length; i++) {
let word = wordArray[i];
word = word.replace(".", "");
word = word.replace(",", "");
word = word.replace(" ", "");
word = word.replace("<mark>", "");
word = word.replace("</mark>", "");
//word = word.replace("\n", " ");

wordArray[i] = word.toLowerCase();
}
return wordArray;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
ticker = {
//if (newPoemButton > 0) {
newPoemButton;

//mutable txt2 = chosenPoem.new.innerHTML;
let lPoem = generateWordArrays(chosenPoem.new);
let poem = genPoemArray[0];
poem = poem.split(" ");
for (let i = 0; i < poem.length; i++) {
poem[i] = randomWord(lPoem[i], poem[i]);
}

poem = poem.join(" ");
genPoemArray[0] = poem;
display4.innerText = poem.replace(/<br>/g, " \n ");

let dict = gibDict;

while (dict.size >= chosenPoem.replace.length) {
yield await Promises.tick(getRandomInt(1000, 1500)).then(() => {
poem = update();
display4.innerText = poem.replace(/<br>/g, " \n ");
});
//}
}
}
Insert cell
update = function() {
let lPoem = generateWordArrays(chosenPoem.new);
let words = genPoemArray[0].split(" "); // split into words

// loop a random number of times: 1 - numberOfPossibleReplacements
//loop from random spot
let r = Math.floor(Math.random() * words.length);
//for (let i = r; i < words.length + r; i++) {
let idx = r % words.length;
words[idx] = randomWord(lPoem[idx], words[idx]);
//}
return words.join(" ");
// mutable txt = RiTa.untokenize(words); // actually even with await Promises ... this does not work
// mutableTxt[0] = RiTa.untokenize(words); // this would also work
}
Insert cell
generateWordArrays(chosenPoem.new)
Insert cell
function generateWordArrays(words1) {
let dict = gibDict;
let wordsArray = words1.innerHTML.split(" ");
//mutable goof = wordsArray;
let cleanArray = cleanWordArrays(wordsArray);
let fullPoem = [];
let langSelected = languages;
for (let ii = 0; ii < cleanArray.length; ii++) {
if (cleanArray[ii] != "<br>") {
let placeholderArray = [];
if (langSelected.indexOf("megan's") != -1) {
placeholderArray.push(cleanArray[ii]);
}
if (langSelected.indexOf("gibberish") != -1) {
placeholderArray.push(dict.get(cleanArray[ii]).gibberishWord);
//mutable goof.push(dict.get(cleanArray[ii]));
}
if (langSelected.indexOf("yours") != -1) {
placeholderArray.push(dict.get(cleanArray[ii]).userSynonym);
}
fullPoem[ii] = placeholderArray;
} else {
fullPoem[ii] = Array("<br>", "<br>", "<br>");
}
}
return fullPoem;
}
Insert cell
function randomWord(wordArray, currentWord) {
// only works with flat arrays of words
let safetyCounter = 0,
word;
do {
word = wordArray[getRandomInt(0, wordArray.length)];
} while (
/*currentWord != undefined && */
word == currentWord &&
safetyCounter++ < 100
);
return word;
}
Insert cell
Insert cell
Insert cell
intersect = function(a, b) {
var setB = new Set(b);
return [...new Set(a)].filter(x => setB.has(x));
}
Insert cell
function gibPoem(oPoem){
let nPoem = oPoem;
for(let ii = 0; ii < oPoem.length; ii++){
if(oPoem[ii] == "-g"){
nPoem[ii] = "-g";
}
else{
nPoem[ii] = generateGibberish(oPoem[ii]);
}
}
return nPoem;
}
Insert cell
Insert cell
mutable txt = ""
Insert cell
mutable txt2 = ""
Insert cell
PrayerStanzas = Prayer.innerHTML.split("<br>")
Insert cell
Insert cell
theThenStanzas = TheThen.innerHTML.split("<br>")
Insert cell
Insert cell
shinDeepStanzas = ShinDeep.innerHTML.split("<br>")
Insert cell
Insert cell
Insert cell
Insert cell
rootWords = [findRootWords(unmutableUnusedWords[0])];
Insert cell
testing2 = findRootWords(["undone", "done", "ouch"]);
Insert cell
display2 = md`Choose a poem then click ‘Prepare Poem’` //Text Box Label
Insert cell
display3 = md`Gibberfy` //Button Label
Insert cell
display5 = md`Prepare Poem`
Insert cell
mutable titleDisplay = ""
Insert cell
Insert cell
Insert cell
prefixes = ["un", "pre", "in"/*this one may be tough*/, "con"]; //need to add more
Insert cell
suffixes = ["ing", "ish", "less", "ee", "ence", "ful" ]; // also need to add more
Insert cell
Insert cell
Prayer = html`<br>
The glow-pink snow<br>
bouncing early sunbeams<br>
onto cracked lids. We weep<br>
and the tears freeze.<br>
<br>
Backs to the ground,<br>
we carve angels with our eyes<br>
clasped shut.<br>
<br>
Pulse warm palms<br>
slow in melting snow.<br>
Breathe the early pollen<br>
<br>
Clumsily, we unfurl,<br>
admire our molds.<br>
We see the holes our bodies leave<br>
and call them angels.<br>
<br>
Underneath, some cracked seeds<br>
unfurl their new tongues.<br>
Others freeze,<br>
clasped palms.`
Insert cell
html`<h3><u>The Then</u></h3>`
Insert cell
TheThen = html`<br>
Who cares about deep violet skies<br>
when nothing is<br>
what is in this what is in<br>
<br>
this forgotten coin collection<br>
I stole from in the memories of summer<br>
with my sister worst case scenerios this is<br>
what I wanted this is what I wanted<br>
<br>
as the sky falls beneath the couch in the<br>
admissions office of God. Hahaha the scholarship<br>
for death where you get to die but painlessly.<br>
Where you get to die but you’re not the one who<br>
<br>
pays. Blood pumps from the chest hammock<br>
to that pitiful raisin brain that can’t even live<br>
can’t even fix the storm-storms it wreaks through<br>
<br>
the bone the tremor jaw the bunch of tooth knuckles<br>
fractures beneath the skin fingerprints sliced and<br>
diced tomato crisis — slices — shit.<br>
<br>
The endless endless, you know?<br>
<br>
The slow slow… the then that never<br>
comes. A life… and the pomegranate grows<br>
a face and says I never wanted you anyway<br>
<br>
never wanted to reunite in the stomach of some<br>
girl in a beach towel desperately trying to claw something<br>
beautiful out of the mucused eggshell stunted<br>
fetus dark-dark never once-living grace of wander<br>
— never beautiful.<br>
<br>
Never was beautiful. All<br>
lies and dramatics.`
Insert cell
html`<h3><u>Shin Deep</u></h3>`
Insert cell
ShinDeep = html`<br>
Apricot jam spread on toast<br>
Tea seethes against painted lips<br>
One the TV lips seethe against each other<br>
Sequined pixels studding screened eyes<br>
<br>
I wake up with early arthritis<br>
And cut through the rotting stem<br>
With sewing shears<br>
Gentle tongue cushion<br>
Sap blood, carbon bone<br>
<br>
Every time I close my eyes<br>
See dying in different ways<br>
<br>
Need help from the fragrant bear<br>
Can no longer sleep as myself<br>
Inside, a shallow ocean shin deep<br>
Can see my toes wriggle beneath<br>
<br>
Breathe in the warm pineapple breeze<br>
And the rolling knell of seagulls<br>
Salt sears lips and nostrils<br>
<br>
Can’t lie down and rest<br>
Not even for a moment<br>
<br>
The water beneath, lung deep.`
Insert cell
Insert cell
Insert cell
genPoem1 = html`early melting <br> we slow our tongues <br> and breathe others <br> palms unfurl <br> carve bodies`
Insert cell
Insert cell
genPoem2 = html`pitiful tooth falls to <br> reunite the sister stomach <br> the deep tomato <br> the never chest <br> <br> fix coin to coin to face <br> To live is mucused beautiful <br> to die is to then live <br> <br> summer is fetus skin <br> desperately wanted`
Insert cell
html`<h3><u>genPoem3</u></h3>`
Insert cell
genPoem3 = html`lips rest against blood breath <br> a warm moment cut <br> on early tongue and bone`
Insert cell
genPoemArray = [chosenPoem.new.innerHTML]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more