Created
February 7, 2019 22:15
-
-
Save aparrish/9593817e59de3adb1c28425056214ae4 to your computer and use it in GitHub Desktop.
allison's assignment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# My amazing RWET assignment yay\n", | |
"\n", | |
"Hi allison I hope you like my good poetry making program." | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## To Make a Dadaist Poem\n", | |
"\n", | |
"Original written by [Tristan Tzara](http://www.391.org/manifestos/1920-dada-manifesto-feeble-love-bitter-love-tristan-tzara.html#.WnPkJYJOndd) in 1920." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 21, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"America. war. the of the to more colonialist intellectual to\n", | |
"beginnings against many outbreak and of nationalist\n", | |
"participants movement the and Dada in broadly bourgeois War\n", | |
"an with World participants, Dadaists corresponded art —\n", | |
"North the war, root Europe conformity Dada cause society\n", | |
"movement, the interests, were protest and many the the The\n", | |
"I. in against and a — was correspond in which believed\n", | |
"cultural and that For was international of informal\n" | |
] | |
} | |
], | |
"source": [ | |
"import random\n", | |
"import textwrap\n", | |
"\n", | |
"newspaper = \"\"\"\n", | |
"Dada was an informal international movement, with \n", | |
"participants in Europe and North America. The \n", | |
"beginnings of Dada correspond to the outbreak of \n", | |
"World War I. For many participants, the movement \n", | |
"was a protest against the bourgeois nationalist \n", | |
"and colonialist interests, which many Dadaists \n", | |
"believed were the root cause of the war, and \n", | |
"against the cultural and intellectual \n", | |
"conformity — in art and more broadly in \n", | |
"society — that corresponded to the war.\"\"\"\n", | |
"\n", | |
"words = newspaper.split()\n", | |
"random.shuffle(words)\n", | |
"\n", | |
"print(textwrap.fill(\" \".join(words), 60))" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## A House of Dust\n", | |
"\n", | |
"Original written in Fortran in 1967 by Alison Knowles and James Tenney. [ELMCIP entry](https://elmcip.net/creative-work/house-dust). [More information](http://blog.calarts.edu/2009/09/10/alison-knowles-james-tenney-and-the-house-of-dust-at-calarts/). [Watch Alison Knowles read from this piece](https://www.youtube.com/watch?v=-68Z708lFsY)." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import random" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 15, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"materials = [\n", | |
" 'shiny steel',\n", | |
" 'aluminum',\n", | |
" 'laser-cut mdf',\n", | |
" 'blinking leds'\n", | |
"]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 16, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"locations = [\n", | |
" 'among high mountains',\n", | |
" 'among other houses',\n", | |
" 'among small hills',\n", | |
" 'by a river',\n", | |
" 'by an abandoned lake',\n", | |
" 'by the sea',\n", | |
" 'in a cold, windy climate',\n", | |
" 'in a deserted airport',\n", | |
" 'in a deserted church',\n", | |
" 'in a deserted factory',\n", | |
" 'in a green, mossy terrain',\n", | |
" 'in a hot climate',\n", | |
" 'in a metropolis',\n", | |
" 'in a place with both heavy rain and bright sun',\n", | |
" 'in an overpopulated area',\n", | |
" 'in dense woods',\n", | |
" 'in heavy jungle undergrowth',\n", | |
" 'in japan',\n", | |
" 'in michigan',\n", | |
" 'in southern france',\n", | |
" 'inside a mountain',\n", | |
" 'on an island',\n", | |
" 'on the sea',\n", | |
" 'underwater'\n", | |
"]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 17, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"lights = [\n", | |
" 'all available lighting',\n", | |
" 'candles',\n", | |
" 'electricity',\n", | |
" 'natural light'\n", | |
"]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 18, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"inhabitants = [\n", | |
" 'all races of men represented wearing predominantly red clothing',\n", | |
" 'children and old people',\n", | |
" 'collectors of all types',\n", | |
" 'fishermen and families',\n", | |
" 'french and german speaking people',\n", | |
" 'friends',\n", | |
" 'friends and enemies',\n", | |
" 'horses and birds',\n", | |
" 'little boys',\n", | |
" 'lovers',\n", | |
" 'people from many walks of life',\n", | |
" 'people speaking many languages wearing little or no clothing',\n", | |
" 'people who eat a great deal',\n", | |
" 'people who enjoy eating together',\n", | |
" 'people who love to read',\n", | |
" 'people who sleep almost all the time',\n", | |
" 'people who sleep very little',\n", | |
" 'various birds and fish',\n", | |
" 'vegetarians',\n", | |
" 'very tall people'\n", | |
"]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 19, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"\n", | |
"A house of laser-cut mdf\n", | |
" inside a mountain\n", | |
" using natural light\n", | |
" inhabited by people who sleep very little\n", | |
"\n", | |
"A house of shiny steel\n", | |
" in an overpopulated area\n", | |
" using natural light\n", | |
" inhabited by people who love to read\n", | |
"\n", | |
"A house of laser-cut mdf\n", | |
" in a place with both heavy rain and bright sun\n", | |
" using all available lighting\n", | |
" inhabited by fishermen and families\n", | |
"\n", | |
"A house of laser-cut mdf\n", | |
" among small hills\n", | |
" using electricity\n", | |
" inhabited by people from many walks of life\n", | |
"\n", | |
"A house of aluminum\n", | |
" in dense woods\n", | |
" using all available lighting\n", | |
" inhabited by fishermen and families\n", | |
"\n", | |
"A house of aluminum\n", | |
" underwater\n", | |
" using candles\n", | |
" inhabited by french and german speaking people\n", | |
"\n", | |
"A house of blinking leds\n", | |
" on the sea\n", | |
" using electricity\n", | |
" inhabited by vegetarians\n" | |
] | |
} | |
], | |
"source": [ | |
"stanza_count = 7\n", | |
"for i in range(stanza_count):\n", | |
" print()\n", | |
" print(\"A house of \" + random.choice(materials))\n", | |
" print(\" \" + random.choice(locations))\n", | |
" print(\" using \" + random.choice(lights))\n", | |
" print(\" inhabited by \" + random.choice(inhabitants))" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Love Letter Generator\n", | |
"\n", | |
"Original by Christopher Strachey, written for the Manchester Mark I in 1952. [Read more here](https://grandtextauto.soe.ucsc.edu/2005/08/01/christopher-strachey-first-digital-artist/).\n", | |
"\n", | |
"Vocabulary based on [this implementation](https://github.com/gingerbeardman/loveletter/blob/master/index.php)." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"sal_adjs = [\n", | |
" \"Beloved\",\n", | |
" \"Darling\",\n", | |
" \"Dear\",\n", | |
" \"Dearest\",\n", | |
" \"Fanciful\",\n", | |
" \"Honey\"]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"sal_nouns = [\n", | |
" \"Chickpea\",\n", | |
" \"Dear\",\n", | |
" \"Duck\",\n", | |
" \"Jewel\",\n", | |
" \"Love\",\n", | |
" \"Moppet\",\n", | |
" \"Sweetheart\"\n", | |
"]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"adjs = [\n", | |
" 'affectionate',\n", | |
" 'amorous',\n", | |
" 'anxious',\n", | |
" 'avid',\n", | |
" 'beautiful',\n", | |
" 'breathless',\n", | |
" 'burning',\n", | |
" 'covetous',\n", | |
" 'craving',\n", | |
" 'curious',\n", | |
" 'eager',\n", | |
" 'fervent',\n", | |
" 'fondest',\n", | |
" 'loveable',\n", | |
" 'lovesick',\n", | |
" 'loving',\n", | |
" 'passionate',\n", | |
" 'precious',\n", | |
" 'seductive',\n", | |
" 'sweet',\n", | |
" 'sympathetic',\n", | |
" 'tender',\n", | |
" 'unsatisfied',\n", | |
" 'winning',\n", | |
" 'wistful'\n", | |
"]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 11, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"nouns = [\n", | |
" 'adoration',\n", | |
" 'affection',\n", | |
" 'ambition',\n", | |
" 'appetite',\n", | |
" 'ardour',\n", | |
" 'being',\n", | |
" 'burning',\n", | |
" 'charm',\n", | |
" 'craving',\n", | |
" 'desire',\n", | |
" 'devotion',\n", | |
" 'eagerness',\n", | |
" 'enchantment',\n", | |
" 'enthusiasm',\n", | |
" 'fancy',\n", | |
" 'fellow feeling',\n", | |
" 'fervour',\n", | |
" 'fondness',\n", | |
" 'heart',\n", | |
" 'hunger',\n", | |
" 'infatuation',\n", | |
" 'little liking',\n", | |
" 'longing',\n", | |
" 'love',\n", | |
" 'lust',\n", | |
" 'passion',\n", | |
" 'rapture',\n", | |
" 'sympathy',\n", | |
" 'thirst',\n", | |
" 'wish',\n", | |
" 'yearning'\n", | |
"]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 12, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"advs = [\n", | |
" 'affectionately',\n", | |
" 'ardently',\n", | |
" 'anxiously',\n", | |
" 'beautifully',\n", | |
" 'burningly',\n", | |
" 'covetously',\n", | |
" 'curiously',\n", | |
" 'eagerly',\n", | |
" 'fervently',\n", | |
" 'fondly',\n", | |
" 'impatiently',\n", | |
" 'keenly',\n", | |
" 'lovingly',\n", | |
" 'passionately',\n", | |
" 'seductively',\n", | |
" 'tenderly',\n", | |
" 'wistfully'\n", | |
"]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 13, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"verbs = [\n", | |
" 'adores',\n", | |
" 'attracts',\n", | |
" 'clings to',\n", | |
" 'holds dear',\n", | |
" 'hopes for',\n", | |
" 'hungers for',\n", | |
" 'likes',\n", | |
" 'longs for',\n", | |
" 'loves',\n", | |
" 'lusts after',\n", | |
" 'pants for',\n", | |
" 'pines for',\n", | |
" 'sighs for',\n", | |
" 'tempts',\n", | |
" 'thirsts for',\n", | |
" 'treasures',\n", | |
" 'yearns for',\n", | |
" 'woos'\n", | |
"]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 14, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Dear Duck,\n", | |
"\n", | |
"You are my lovesick being: my beautiful fellow feeling. My\n", | |
"fancy impatiently tempts your precious longing. You are my\n", | |
"covetous fondness: my eager fondness.\n", | |
"\n", | |
"Yours fervently,\n", | |
"M.U.C.\n" | |
] | |
} | |
], | |
"source": [ | |
"# textwrap library used to \"wrap\" the text at a particular length\n", | |
"import textwrap\n", | |
"\n", | |
"# output begins with salutation\n", | |
"output = random.choice(sal_adjs) + \" \" + random.choice(sal_nouns) + \",\\n\"\n", | |
"output += \"\\n\"\n", | |
"\n", | |
"# inside this loop, build the phrases. strachey implemented \"short\" phrases\n", | |
"# and \"long\" phrases; two or more \"short\" phrases in a row have special\n", | |
"# formatting rules, so we need to know what the last phrase kind was in\n", | |
"# order to generate the output.\n", | |
"history = []\n", | |
"body = \"\"\n", | |
"for i in range(5):\n", | |
" kind = random.choice([\"short\", \"long\"])\n", | |
" if kind == \"long\":\n", | |
" # adjectives and adverbs will be present only 50% of the time\n", | |
" line = \" \".join([\n", | |
" \"My\",\n", | |
" random.choice([random.choice(adjs), \"\"]),\n", | |
" random.choice(nouns),\n", | |
" random.choice([random.choice(advs), \"\"]),\n", | |
" random.choice(verbs),\n", | |
" \"your\",\n", | |
" random.choice([random.choice(adjs), \"\"]),\n", | |
" random.choice(nouns)])\n", | |
" body += line\n", | |
" else:\n", | |
" adj_noun = random.choice(adjs) + \" \" + random.choice(nouns)\n", | |
" # if the last phrase was \"short,\" use truncated form\n", | |
" if len(history) > 0 and history[-1] == \"short\":\n", | |
" body += \": my \" + adj_noun\n", | |
" else:\n", | |
" body += \"You are my \" + adj_noun\n", | |
" body += \". \"\n", | |
" history.append(kind)\n", | |
"# clean up output\n", | |
"body = body.replace(\" \", \" \")\n", | |
"body = body.replace(\". :\", \":\")\n", | |
"# put everything together\n", | |
"output += textwrap.fill(body, 60)\n", | |
"output += \"\\n\\nYours \" + random.choice(advs) + \",\\n\"\n", | |
"output += \"M.U.C.\"\n", | |
"print(output)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Taroko Gorge\n", | |
"\n", | |
"[Original](http://nickm.com/taroko_gorge/) by [Nick Montfort](http://nickm.com/). [ELMCIP entry here](https://elmcip.net/creative-work/taroko-gorge)." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 15, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"above = ['brow', 'mist', 'shape', 'layer', 'the crag', 'stone', 'forest', 'height']\n", | |
"below = ['flow', 'basin', 'shape', 'vein', 'rippling', 'stone', 'cove', 'rock']\n", | |
"transitive = ['command', 'pace', 'roam', 'trail', 'frame', 'sweep', 'exercise', 'range']\n", | |
"imperative = ['track', 'shade', 'translate', 'stamp', 'progress through', 'direct', 'run', 'enter']\n", | |
"intransitive = ['linger', 'dwell', 'rest', 'relax', 'hold', 'dream', 'hum']\n", | |
"texture = ['rough', 'fine']\n", | |
"adjectives = ['encompassing', 'sinuous', 'straight', 'objective', 'arched', 'cool', 'clear', 'dim', 'driven']" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 16, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def path():\n", | |
" plural = random.sample([\"s\", \"\"], k=2)\n", | |
" words = random.choice(above)\n", | |
" if words == \"forest\" and random.randrange(4) == 0:\n", | |
" words = \"monkeys\" + \" \" + random.choice(transitive)\n", | |
" else:\n", | |
" words += plural[0] + \" \" + random.choice(transitive) + plural[1]\n", | |
" words += \" the \" + random.choice(below) + random.choice([\"s\", \"\"]) + \".\"\n", | |
" return words.capitalize()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 17, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def cave():\n", | |
" adjs = adjectives[:] + random.sample(texture, 1)\n", | |
" return \" \" + random.choice(imperative) + \" \" + \\\n", | |
" \" \".join(random.sample(adjs, random.randrange(1, 4))) + \" —\"" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 18, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def site():\n", | |
" if random.randrange(2) == 0:\n", | |
" words = random.choice(above)\n", | |
" else:\n", | |
" words = random.choice(below)\n", | |
" words += \"s \" + random.choice(intransitive) + \".\"\n", | |
" return words.capitalize()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 19, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Layer frames the ripplings.\n", | |
"Stones relax.\n", | |
"Mist trails the rocks.\n", | |
"\n", | |
" translate rough —\n", | |
"\n", | |
"Heights roam the rocks.\n", | |
"Stones dream.\n", | |
"Stones dream.\n", | |
"Shape frames the coves.\n", | |
"\n", | |
" progress through sinuous fine dim —\n", | |
"\n", | |
"Brows trail the shapes.\n", | |
"Stone trails the flow.\n", | |
"\n", | |
" run encompassing —\n", | |
"\n", | |
"Stones command the stones.\n", | |
"Brow sweeps the stone.\n", | |
"\n", | |
" progress through sinuous cool dim —\n", | |
"\n", | |
"Mists command the coves.\n", | |
"Veins hum.\n", | |
"Shapes dream.\n", | |
"Shapes pace the vein.\n", | |
"\n", | |
" stamp driven objective encompassing —\n", | |
"\n", | |
"Forests range the cove.\n", | |
"Flows rest.\n", | |
"Forests hold.\n", | |
"Mists frame the veins.\n", | |
"\n", | |
" enter driven —\n", | |
"\n", | |
"Height paces the flow.\n", | |
"Ripplings dwell.\n", | |
"Brow commands the stones.\n", | |
"\n", | |
" enter fine —\n", | |
"\n", | |
"Brows roam the flow.\n", | |
"Basins hum.\n", | |
"Shape frames the veins.\n", | |
"\n", | |
" progress through clear —\n", | |
"\n", | |
"The crag exercises the flow.\n", | |
"Forests rest.\n", | |
"Layer frames the flows.\n", | |
"\n", | |
" translate encompassing objective sinuous —\n", | |
"\n", | |
"Heights sweep the coves.\n", | |
"Shapes trail the stones.\n", | |
"\n", | |
" stamp driven —\n", | |
"\n" | |
] | |
} | |
], | |
"source": [ | |
"stanza_count = 10\n", | |
"for repeat in range(stanza_count):\n", | |
" line_count = random.randrange(3, 6)\n", | |
" for i in range(line_count):\n", | |
" if i == 0:\n", | |
" print(path())\n", | |
" elif i == line_count - 2:\n", | |
" print(path())\n", | |
" elif i == line_count - 1:\n", | |
" print()\n", | |
" print(cave())\n", | |
" print()\n", | |
" else:\n", | |
" print(site())" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.5" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment