Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
{
"cells": [
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import pickle\n",
"\n",
"spencer_bios = pickle.load(open('bios.pickle', 'rb'))"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"740"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(spencer_bios)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"white_bios = []\n",
"\n",
"for bio in spencer_bios:\n",
" if bio == '':\n",
" spencer_bios.remove(bio)\n",
" if bio == ' ':\n",
" spencer_bios.remove(bio)\n",
" words = bio.split()\n",
" for word in words:\n",
" if word.lower().find('white'.lower()) != -1:\n",
" white_bios.append(bio)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"23"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(white_bios)"
]
},
{
"cell_type": "code",
"execution_count": 103,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"u'MOSTLIVESMATTER-BIGGOVSUCKS- BENEFICIARY OF THE IMAGINARY WHITE PRIVILEGE'"
]
},
"execution_count": 103,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"white_bios[0]"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"baldwin = open('letter-from-a-region-baldwin.txt').read()"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"white_lines = []\n",
"lines = baldwin.split('.')\n",
"for line in lines:\n",
" if line.lower().find('white'.lower()) != -1:\n",
" white_lines.append(line)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'\\xe2\\x80\\x9d They began to care less about the way they looked, the way they dressed, the things they did; presently, one found them in twos and threes and fours, in a hallway, sharing a jug of wine or a bottle of whiskey, talking, cursing, fighting, sometimes weeping: lost, and unable to say what it was that oppressed them, except that they knew it was \\xe2\\x80\\x9cthe man\\xe2\\x80\\x9d\\xe2\\x80\\x94the white man'"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"white_lines[0]"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"You're being brainwashed and lied to. #WhiteGenocide is real. Ban #Islam. #Liberals are filthy. Memes are funny. #AltRight #Trump #UKIP #WhitePride #MarineLePen\n",
"----------\n",
" You must consider what happens to this citizen, after all he has endured, when he returns—home: starch, in his shoes, for a job, for a place to live; ride, in his skin, on segregated buses; see, with his eyes, the signs saying “White” and “Colored,” and especially the signs that say “White Ladies” and “Colored Women;” look into the eyes of his wife; look into the eyes of his son; listen, with his ears, to political speeches, North and South; imagine yourself being told to “wait\n"
]
}
],
"source": [
"import random\n",
"picker1 = random.randrange(0, len(white_bios), 1)\n",
"picker2 = random.randrange(0, len(white_lines), 1)\n",
"print white_bios[picker1]\n",
"print '----------'\n",
"print white_lines[picker2]"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.12"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.