Skip to content

Instantly share code, notes, and snippets.

@mgiraldo
Last active August 29, 2015 14:07
Show Gist options
  • Save mgiraldo/cf9ebcee46ad8958c90f to your computer and use it in GitHub Desktop.
Save mgiraldo/cf9ebcee46ad8958c90f to your computer and use it in GitHub Desktop.
single label book classifier
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"name": "",
"signature": "sha256:24b7b5730330dd7d18f6fe480d099f4818ffc372516f29d1f7cba9429d6223cc"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Single label book appeal classifier"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Basic book appeal classification code."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from sklearn import linear_model\n",
"from sklearn import cross_validation\n",
"import numpy as np\n",
"import csv"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"General functions"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# converts a string to a float\n",
"# used by data_load_parse()\n",
"def str_to_float(x):\n",
" try:\n",
" if x=='': return 0.0\n",
" if x=='false': return 0.0\n",
" if x=='true': return 1.0\n",
" return float(float(x)>0)\n",
" except:\n",
" print(\"[{x}] is not a float\".format(x=x))"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 2
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# given a path to csv, generate a bidimensional list\n",
"# ignores first row\n",
"def data_load(path):\n",
" return [x for x in csv.reader(open(path))][1:]"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 3
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# extracts labels and word data from a properly-formatted csv\n",
"def data_parse(raw_data):\n",
" data = []\n",
" for row in raw_data:\n",
" data.append([str_to_float(x) for x in row[2:]])\n",
" labels = [x[1] for x in raw_data]\n",
" return labels, data"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 4
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"The classifier itself"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"def train_classifier(data, labels):\n",
" clf = linear_model.LogisticRegression()\n",
" clf.fit(data, labels)\n",
" return clf"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 5
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Saving the classifier to disk"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import cPickle\n",
"\n",
"# save the classifier\n",
"def save_classifier(classifier, path):\n",
" with open(path, 'wb') as fid:\n",
" cPickle.dump(classifier, fid)\n",
"\n",
"# load it again\n",
"def load_classifier(path):\n",
" with open(path, 'rb') as fid:\n",
" classifier = cPickle.load(fid)\n",
" return classifier"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 6
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To plot precision:"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# from: http://www.astro.washington.edu/users/vanderplas/Astr599/notebooks/18_IntermediateSklearn.html\n",
"import matplotlib.pyplot as plt\n",
"from sklearn import metrics\n",
"%matplotlib inline\n",
"def plot_confusion_matrix(pred, y):\n",
" print \" accuracy:\", metrics.accuracy_score(y, pred)\n",
" print \" precision:\", metrics.precision_score(y, pred)\n",
" print \" recall:\", metrics.recall_score(y, pred)\n",
" print \" f1 score:\", metrics.f1_score(y, pred)\n",
" \n",
" plt.imshow(metrics.confusion_matrix(y, pred),\n",
" cmap=plt.cm.binary, interpolation='nearest')\n",
" plt.colorbar()\n",
" plt.xlabel('true value')\n",
" plt.ylabel('predicted value')"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 7
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Combined function to train and plot classifier accuracy:"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"def test_accuracy(data, labels):\n",
" tr_data, te_data, tr_labels, te_labels = cross_validation.train_test_split(data, labels, test_size=0.3)\n",
" clf = train_classifier(tr_data, tr_labels)\n",
" pred = clf.predict(te_data)\n",
" plot_confusion_matrix(te_labels, pred)"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 8
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Usage"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"First get the data organized:"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# separate CSV into training and testing data\n",
"raw_data = data_load('/Users/mga/Desktop/train.csv')\n",
"all_labels, all_data = data_parse(raw_data)\n",
"training_data = all_data\n",
"training_labels = all_labels"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 9
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Some decoration to view our results better:"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# test data has book info in columns 0,1 and reviews in 2:n\n",
"raw_test_data = data_load('/Users/mga/Desktop/test.csv')\n",
"empty, test_data = data_parse([x[2:] for x in raw_test_data])\n",
"books = [row[1:2] for row in raw_test_data]"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 10
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Test accuracy of classifier:"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"test_accuracy(training_data, training_labels)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" accuracy: "
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"0.51768488746\n",
" precision: 0.529318963237\n",
" recall: 0.51768488746\n",
" f1 score: 0.521151924549\n"
]
},
{
"metadata": {},
"output_type": "display_data",
"png": "iVBORw0KGgoAAAANSUhEUgAAAUgAAAEPCAYAAAAgSV3nAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHE1JREFUeJzt3XuYFNWZx/HvDDpBwQvEBEchQVSIslEGJzgqxolRH0RD\ndOMaXe+SxBvq8hiDJmaF7GbjZY3G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ZKefG+KQx010703NuIlY9b8HeSWbS9Kb/M6x02Yq9r8w00swBfg78LzY11xPYTN8iIiIi\nIiIiIiIiIiIiIiIiIiIiIiIiIlLp/h/zQqMfijjQawAAAABJRU5ErkJggg==\n",
"text": [
"<matplotlib.figure.Figure at 0x10a71e690>"
]
}
],
"prompt_number": 11
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now train final classifier:"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"classifier = train_classifier(training_data, training_labels)\n",
"classifier"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 12,
"text": [
"LogisticRegression(C=1.0, class_weight=None, dual=False, fit_intercept=True,\n",
" intercept_scaling=1, penalty='l2', random_state=None, tol=0.0001)"
]
}
],
"prompt_number": 12
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Computer: _ENHANCE_!"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# example prediction\n",
"classifier.predict(test_data[0])"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 13,
"text": [
"array(['Character'], \n",
" dtype='|S9')"
]
}
],
"prompt_number": 13
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Pair that with the \"decoration\" data (can't plot because appeal is unknown):"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"for idx, row in enumerate(test_data):\n",
" print classifier.predict(row), books[idx]"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"['Character'] [\"Assassin's Apprentice\"]\n",
"['Setting'] ['American Gods']\n",
"['Story'] ['Someone to Watch Over Me']\n",
"['Story'] ['3rd Degree']\n",
"['Story'] [\"Brian's Winter\"]\n",
"['Story'] ['The Poet']\n",
"['Character'] ['She Comes First']\n",
"['Story'] ['Skeleton Canyon']\n",
"['Story'] ['Map of Bones']\n",
"['Story'] ['2nd Chance']\n",
"['Story'] ['Mystic River']\n",
"['Character'] ['The Pilgrimage']\n",
"['Story'] ['The Book of the Dead']\n",
"['Character'] ['Freakonomics']\n",
"['Language'] ['The Year of Magical Thinking']\n",
"['Setting'] ['Lake in the Clouds']\n",
"['Story'] ['Kiss of Crimson']\n",
"['Story'] ['The E-Myth Revisited']\n",
"['Character'] ['You Can Heal Your Life']\n",
"['Story'] ['The Black Echo']\n",
"['Character'] ['With the Old Breed']\n",
"['Character'] ['The Fifth Elephant']\n",
"['Story'] ['Her Royal Spyness']\n",
"['Story'] ['Shadow Kiss']\n",
"['Story'] ['Salvation in Death']\n",
"['Story'] ['Wait Till Helen Comes']\n",
"['Story'] ['Who']\n",
"['Story'] ['Wicked Prey']\n",
"['Language'] ['Mere Christianity']\n",
"['Story'] ['The Strain']\n",
"['Story'] ['Chosen To Die']\n",
"['Story']"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" ['Angel Time']\n",
"['Setting'] ['New York']\n",
"['Story'] ['Heartless']\n",
"['Character'] ['The 4-Hour Workweek']\n",
"['Language'] ['Linchpin']\n",
"['Story'] ['Horns']\n",
"['Story'] ['The Partner']\n",
"['Story'] ['The Testament']\n",
"['Story'] ['Fast Food Nation']\n",
"['Story'] ['Summer Secrets']\n",
"['Language'] ['One Thousand Gifts']\n",
"['Language'] [\"Foucault's Pendulum\"]\n",
"['Setting'] ['Gregor the Overlander']\n",
"['Story'] ['Naked Heat']\n",
"['Character'] ['Attachments']\n",
"['Setting'] ['The Worst Hard Time']\n",
"['Character'] ['Lost in Shangri-La']\n",
"['Character'] ['True Grit']\n",
"['Character'] ['Destiny of the Republic']\n",
"['Character'] ['Maisie Dobbs']\n",
"['Setting'] ['Portrait of a Spy']\n",
"['Story'] ['Buried Prey']\n",
"['Story'] ['Men, Women & Children']\n",
"['Story'] [\"If He's Dangerous\"]\n",
"['Story'] ['Heart-Shaped Box']\n",
"['Story'] ['Kill Alex Cross']\n",
"['Story'] ['Born to Die']\n",
"['Character'] ['Auschwitz']\n",
"['Language'] ['The Magician King']\n",
"['Character'] ['The Happiness Trap']\n",
"['Story'] ['New York to Dallas']\n",
"['Character']"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" ['Fires of Winter']\n",
"['Setting'] ['Darth Plagueis']\n",
"['Character'] ['A Confident Heart']\n",
"['Story'] ['Say You Love Me']\n",
"['Character'] ['Desert Solitaire']\n",
"['Character'] ['Crucial Conversations Tools for Talking When Stakes Are High']\n",
"['Character'] ['Jesus Calling']\n",
"['Story'] ['A Rogue By Any Other Name']\n",
"['Setting'] ['The Moonlit Mind (Novella)']\n",
"['Character'] ['Odd Apocalypse']\n",
"['Story'] ['The Last Victim']\n",
"['Story'] ['Choose to Lose']\n",
"['Story'] ['Wrath']\n",
"['Story'] ['Afraid to Die']\n",
"['Story'] ['The Fallen Angel']\n",
"['Story'] ['A Wanted Man']\n",
"['Setting'] ['Live by Night']\n",
"['Story'] ['Nowhere to Hide']\n",
"['Setting'] ['Summer Nights']\n",
"['Story'] ['Phantom Shadows']\n",
"['Character'] [\"Not Your Mother's Rules\"]\n",
"['Character'] ['Any Duchess Will Do']\n",
"['Story'] [\"Lord Stillwell's Excellent Engagements\"]\n",
"['Setting'] ['Cole Trilogy']\n",
"['Story'] ['Training the Best Dog Ever']\n",
"['Story'] ['Lyra Novels']\n",
"['Story'] ['The Virgin Diet: Drop 7 Foods, Lose 7 Pounds, Just 7 Days']\n",
"['Character'] ['Lean In']\n",
"['Language'] ['Big Girl Panties']\n",
"['Story'] ['A Kiss For Midwinter']\n",
"['Story'] ['Marathon Man']\n",
"['Story'] ['The Song of the Quarkbeast']\n",
"['Setting']"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" ['Inferno']\n",
"['Story'] ['The Best American Mystery Stories 2013']\n",
"['Character'] ['The Light in the Ruins']\n",
"['Story'] ['Spirit']\n",
"['Story'] ['The Hidden Kingdom']\n",
"['Story'] ['Think Like a Freak']\n",
"['Language'] ['The Wicked Wallflower']\n",
"['Character'] ['Allegiant']\n",
"['Story'] ['The Crush']\n",
"['Character'] ['Jesus > Religion']\n",
"['Story'] ['The Night Before']\n",
"['Character'] ['Just What Kind of Mother Are You?']\n",
"['Story'] ['Pros and Cons']\n",
"['Story'] ['The Beach House']\n",
"['Story'] ['Sycamore Row']\n",
"['Story'] ['Lethal Pursuit']\n",
"['Story'] ['Falling for a Stranger']\n",
"['Story'] ['Bitter Sweet Love']\n",
"['Story'] ['No Escape']\n",
"['Character'] ['A Well-tempered Heart']\n",
"['Character'] ['The One']\n",
"['Setting'] ['The Care and Management of Lies']\n",
"['Character'] ['Blossom Street Brides']\n",
"['Setting'] ['The Queen of the Tearling']\n",
"['Setting'] [\"Asia's Cauldron\"]\n",
"['Character'] [\"No Sunshine When She's Gone\"]\n",
"['Story'] ['The Son']\n",
"['Story'] ['The Unburied Dead']\n",
"['Story'] ['The Marriage Pact']\n",
"['Story'] ['The Rancher and the Runaway Bride Part 3']\n",
"['Character'] ['The Girls from Corona del Mar']\n",
"['Setting'] ['The Promise']\n",
"['Character']"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" [\"Zen Mind, Beginner's Mind\"]\n",
"['Character'] ['Biohazard']\n",
"['Character'] ['Dear Committee Members']\n",
"['Character'] ['Angels of Abundance']\n",
"['Character'] ['The Stolen']\n",
"['Story'] ['Highland Wolf Christmas']\n",
"['Character'] [\"Fatty O'Leary's Dinner Party\"]\n",
"['Language'] ['The Spell of the Sensuous']\n",
"['Story'] ['Afterburn & Aftershock']\n",
"['Character'] ['Their Eyes Were Watching God']\n",
"['Story'] ['Forbidden Ground']\n",
"['Story'] ['Drone Strike']\n",
"['Character'] ['Living Violet']\n",
"['Story'] ['Turned']\n",
"['Language'] ['Vowed']\n",
"['Story'] ['The Carpet People']\n",
"['Character'] ['The Rancher and the Runaway Bride Part 2']\n",
"['Setting'] ['Ultimate Guide to Google AdWords']\n",
"['Story'] ['The Witch Is Back (with bonus short story Be Witched)']\n",
"['Setting'] ['Unexpected Stories']\n",
"['Story'] [\"An Indigenous Peoples' History of the United States\"]\n",
"['Character'] ['Truth or Dare']\n",
"['Story'] ['The First Family Detail']\n",
"['Character'] ['French Pastry Murder']\n",
"['Story'] ['My Lord Vampire']\n",
"['Setting'] ['The Fiery Cross']\n",
"['Setting'] ['The Guns of August']\n",
"['Language'] ['Four Divergent Stories']\n",
"['Language'] ['The Night Garden']\n",
"['Character'] [\"In the President's Secret Service\"]\n",
"['Story'] ['The Adventures of Super Diaper Baby']\n",
"['Setting'] ['The Betrayed']\n",
"['Setting']"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" ['Sabriel']\n",
"['Story'] ['Romancing Mister Bridgerton']\n",
"['Setting'] ['The River of Doubt']\n",
"['Character'] ['The Lightning Thief']\n",
"['Character'] ['Born to Run']\n",
"['Story'] ['The Rainmaker']\n",
"['Story'] ['A Drink Before the War']\n",
"['Story'] ['Loved']\n",
"['Story'] ['Out of Control']\n",
"['Story'] ['Silent Run']\n",
"['Character'] ['What on Earth Am I Here For?']\n",
"['Story'] [\"It's Halloween, I'm Turning Green!\"]\n",
"['Character'] ['Shadows of the Workhouse']\n",
"['Story'] ['Unspoken']\n",
"['Story'] [\"Dead Man's Mirror\"]\n",
"['Character'] ['The Romance']\n",
"['Character'] ['My Life with the Walter Boys']\n",
"['Story'] ['Act of Will']\n",
"['Story'] ['Cowboy Take Me Away']\n",
"['Setting'] ['Augustus']\n",
"['Story'] ['Entre Naranjos']\n",
"['Story'] ['Total Control']\n",
"['Setting'] ['Eragon']\n",
"['Story'] ['Persuader']\n",
"['Story'] ['Payment in Kind']\n",
"['Language'] ['A Tree Grows in Brooklyn']\n",
"['Setting'] ['Homeplace']\n",
"['Story'] ['Living Dead in Dallas']\n",
"['Story'] ['Payback']\n",
"['Language'] ['Healthy Sleep Habits, Happy Child']\n",
"['Setting'] ['A Walk in the Woods']\n",
"['Story'] ['Life Expectancy']\n",
"['Character']"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" ['The Mysterious Benedict Society']\n",
"['Story'] ['One False Move']\n",
"['Story'] ['Guards! Guards!']\n",
"['Character'] ['Good Calories, Bad Calories']\n",
"['Setting'] ['The Color of Magic']\n",
"['Language'] ['Crossing to Safety']\n",
"['Story'] ['From Dead to Worse']\n",
"['Setting'] ['Dune Messiah']\n",
"['Character'] ['The Last Lecture']\n",
"['Story'] ['Saving Faith']\n",
"['Story'] ['The Kill Artist']\n",
"['Setting'] ['The Warded Man']\n",
"['Character'] ['Act Like a Lady, Think Like a Man']\n",
"['Character'] ['The Neighbor']\n",
"['Story'] ['The Hunt for Red October']\n",
"['Character'] ['In Bed With A Stranger']\n",
"['Story'] ['Too Much Temptation']\n",
"['Language'] ['The Things They Carried']\n",
"['Story'] ['Big Jack']\n",
"['Story'] ['Something About You']\n",
"['Character'] ['So Long Insecurity']\n",
"['Character'] ['Orange Is the New Black']\n",
"['Character'] ['Secret Daughter']\n",
"['Character'] ['Water for Elephants']\n",
"['Language'] ['The Whistling Season']\n",
"['Language'] ['Stoner']\n",
"['Story'] ['The Kings of Clonmel']\n",
"['Character'] ['American Psycho']\n",
"['Story'] ['The Rembrandt Affair']\n",
"['Story'] ['Flowers for Algernon']\n",
"['Language'] ['This World We Live In']\n",
"['Character'] ['Fear and Loathing in Las Vegas']\n",
"['Story']"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" ['Time to Hunt']\n",
"['Story'] ['Backstage Pass']\n",
"['Story'] ['Last Sacrifice']\n",
"['Story'] ['The Personal MBA']\n",
"['Language'] ['Are You My Mother?']\n",
"['Language'] ['Necessary Endings']\n",
"['Language'] ['The Maltese Falcon']\n",
"['Story'] ['Ghost Story']\n",
"['Character'] ['1Q84']\n",
"['Language'] ['Lola and the Boy Next Door']\n",
"['Story'] ['One True Love']\n",
"['Character'] ['Ch\\xc3\\xa9ri']\n",
"['Story'] ['Heinrich Himmler']\n",
"['Story'] ['The Lemonade Crime']\n",
"['Setting'] ['Desired']\n",
"['Story'] ['Tricked']\n",
"['Character'] ['Be Here Now']\n",
"['Story'] ['The Girl With the Dragon Tattoo Trilogy Bundle']\n",
"['Character'] ['Some Came Running']\n",
"['Story'] ['Coming Home']\n",
"['Character'] ['Into the Free']\n",
"['Story'] ['Harry Potter and the Goblet of Fire']\n",
"['Story'] ['A Deeper Darkness']\n",
"['Story'] ['The Scoop']\n",
"['Language'] ['One Good Earl Deserves a Lover']\n",
"['Character'] ['The Governess Affair']\n",
"['Story'] ['The Custom of the Army']\n",
"['Character'] ['The Dragonet Prophecy']\n",
"['Story'] ['The Last Dragonslayer']\n",
"['Character'] ['Democracy in America']\n",
"['Story'] ['Tracker']\n",
"['Story'] ['Twice Tempted']\n",
"['Character']"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" ['Pavilion of Women']\n",
"['Story'] ['The Cider House Rules']\n",
"['Character'] ['The Stranger']\n",
"['Story'] ['Writing Better Lyrics']\n",
"['Character'] ['Animal Wise']\n",
"['Character'] ['Etched in Sand']\n",
"['Story'] ['How Hard Can It Be']\n",
"['Language'] ['The Woman Upstairs']\n",
"['Character'] ['Fifty Shades of Kale']\n",
"['Character'] ['Heart of Palm']\n",
"['Language'] ['Eat Q']\n",
"['Story'] ['The Bitter Kingdom']\n",
"['Language'] ['The Luminaries']\n",
"['Character'] ['Lawrence in Arabia']\n",
"['Story'] ['Ready to Die']\n",
"['Language'] ['Raspberry Pi For Dummies']\n",
"['Character'] ['Something Wicked This Way Comes']\n",
"['Story'] ['Flintlock']\n",
"['Character'] ['Things That Matter']\n",
"['Story'] ['A Tale of Two Dragons']\n",
"['Character'] ['Three Weeks With Lady X']\n",
"['Story'] ['Warriors']\n",
"['Story'] ['What She Left Behind']\n",
"['Character'] ['Death of a Chocoholic']\n",
"['Character'] ['Bridge to Haven']\n",
"['Character'] ['Harvest Home']\n",
"['Character'] ['God and the Gay Christian']\n",
"['Language'] ['The Given']\n",
"['Setting'] ['Texas']\n",
"['Character'] ['America']\n",
"['Setting'] ['The Returned']\n",
"['Character']"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" ['A Little Bit Country']\n",
"['Story'] ['Fake It']\n",
"['Story'] ['Chance for Love']\n",
"['Story'] ['Lords of the Underworld Bundle 1: The Darkest Night\\\\The Darkest Kiss\\\\The Darkest Pleasure']\n",
"['Character'] ['A Spy Among Friends']\n",
"['Story'] ['All a Heart Needs']\n",
"['Language'] ['To Be the Best']\n",
"['Language'] ['The Narrow Road to the Deep North']\n",
"['Story'] ['What Color Is Your Parachute? 2015']\n",
"['Story'] ['The Queen of Zombie Hearts']\n",
"['Character'] ['Broken']\n",
"['Character'] ['Dataclysm']\n",
"['Story'] ['The Stone Wife']\n",
"['Language'] ['Sunshine on Scotland Street']\n",
"['Character'] ['Our First Christmas']\n",
"['Character'] ['Brain Rules']\n",
"['Setting'] ['The Half Has Never Been Told']\n",
"['Story'] ['Going Gone']\n",
"['Language'] ['Jubilee Trail']\n",
"['Story'] ['Invincible']\n",
"['Story'] ['Sudden Danger']\n",
"['Character'] ['The Seven Storey Mountain']\n",
"['Story'] [\"Harry Potter and the Sorcerer's Stone\"]\n",
"['Language'] ['The Success Principles&trade;']\n",
"['Character'] ['Six Days of the Condor']\n",
"['Language'] ['The Duke and I']\n",
"['Language'] ['Love']\n",
"['Setting'] ['Hawaii']\n",
"['Story'] ['Thud!']\n",
"['Story']"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" ['Magic Hour']\n",
"['Character'] ['As I Lay Dying']\n",
"['Character'] ['Dad is Fat']\n",
"['Story'] [\"The Highlander's Bride\"]\n",
"['Story'] ['Police']\n",
"['Story'] ['Toxic']\n",
"['Story'] [\"Stanislaski's Bundle 1 of 2: Considering Kate\\\\Convincing Alex\\\\Falling for Rachel\"]\n",
"['Character'] ['The Proposal']\n",
"['Story'] ['Come the Morning']\n",
"['Language'] ['The Remedy for Love']\n",
"['Character'] ['The Proper Care and Feeding of Husbands']\n",
"['Story'] ['The Lord John Series 4-Book Bundle']\n",
"['Story'] ['Indecent Proposal']\n",
"['Story'] ['Bones Never Lie']\n",
"['Story'] ['Countdown']\n",
"['Character'] ['The Primal Blueprint']\n",
"['Story'] ['A Reign of Steel']\n",
"['Story'] ['Molly Fyde and the Parsona Rescue']\n",
"['Story'] ['Louisa']\n",
"['Story'] ['A Dance with Dragons']\n",
"['Story'] ['Tombstone Courage']\n",
"['Character'] ['Tuesdays With Morrie']\n",
"['Setting'] ['The China Study']\n",
"['Character'] ['Mary Poppins Comes Back']\n",
"['Setting'] ['The Psychopath Test']\n",
"['Character'] ['Exodus']\n",
"['Story'] ['Brawn']\n",
"['Language'] ['The Round House']\n",
"['Character'] ['NOS4A2']\n",
"['Story'] ['Two of a Kind']\n",
"['Character'] ['Minerva']\n",
"['Story'] ['Takedown Twenty']\n",
"['Character']"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" ['King Must Die']\n",
"['Story'] ['The Paris Architect']\n",
"['Story'] ['Nash']\n",
"['Character'] ['This Kind of War']\n",
"['Character'] [\"Kate's Vow\"]\n",
"['Character'] ['The Paris Wife']\n",
"['Story'] ['The Wanderer']\n",
"['Character'] ['The Brain That Changes Itself']\n",
"['Story'] ['Violets Are Blue']\n",
"['Story'] ['Animating Maria']\n",
"['Story'] ['The Valhalla Prophecy']\n",
"['Story'] ['Jack & Jill']\n",
"['Character'] ['The Intelligent Investor, Revised Edition']\n",
"['Story'] ['Murder on the Orient Express']\n",
"['Story'] ['Time to Murder and Create']\n",
"['Story'] ['Worst Fears Realized']\n",
"['Character'] ['The Book of Joe']\n",
"['Setting'] ['A Clash of Kings']\n",
"['Character'] ['In Cold Blood']\n",
"['Story'] ['The River']\n",
"['Character'] ['The Seven Principles for Making Marriage Work']\n",
"['Story'] ['The Enemy']\n",
"['Story'] ['And Then There Were None']\n",
"['Character'] ['Never Let Me Go']\n",
"['Story'] ['True Believer']\n",
"['Story'] ['Black Order']\n",
"['Setting'] ['Dead as a Doornail']\n",
"['Language'] ['The Road']\n",
"['Character'] ['Echo Park']\n",
"['Language'] ['The Shadow of the Wind']\n",
"['Story'] ['Step on a Crack']\n",
"['Language'] ['The Notebook']\n",
"['Character'] ['Reaper Man']\n",
"['Language']"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" ['Looking for Salvation at the Dairy Queen']\n",
"['Character'] ['The Wolf of Wall Street']\n",
"['Story'] ['Nothing to Lose']\n",
"['Character'] ['Battlefield of the Mind']\n",
"['Story'] ['Cowgirl Up and Ride']\n",
"['Character'] ['The Art of Racing in the Rain']\n",
"['Story'] ['Left to Die']\n",
"['Story'] ['Tied Up, Tied Down']\n",
"['Story'] ['The Rescue']\n",
"['Setting'] ['The Lion, the Witch and the Wardrobe']\n",
"['Character'] ['Bridge to Terabithia']\n",
"['Character'] ['The Sweetness at the Bottom of the Pie']\n",
"['Story'] ['The Defector']\n",
"['Character'] ['Sojourn']\n",
"['Character'] ['\"U\" is for Undertow']\n",
"['Character'] ['I Hope They Serve Beer In Hell']\n",
"['Story'] ['The Dead and the Gone']\n",
"['Story'] ['Fallen']\n",
"['Story'] ['Vanishing Act']\n",
"['Story'] ['Caught']\n",
"['Story'] ['Sandman Slim']\n",
"['Setting'] ['The Burning Land']\n",
"['Story'] ['Private']\n",
"['Story'] ['Ice Cold']\n",
"['Story'] ['The Cold Commands']\n",
"['Story'] ['The Host']\n",
"['Character'] ['Beautiful Boy']\n",
"['Language'] ['The Heart Is a Lonely Hunter']\n",
"['Setting'] ['Linger']\n",
"['Character'] ['Will Grayson, Will Grayson']\n",
"['Story'] ['The Lost Hero']\n",
"['Character'] ['The Big Burn']\n",
"['Character'] ['The Belly Fat Cure']\n",
"['Story']"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" ['Fix, Freeze, Feast']\n",
"['Story'] ['Chasing Fire']\n",
"['Story'] ['Harvest Moon']\n",
"['Story'] ['Threat Warning']\n",
"['Story'] ['Some Kind of Wonderful']\n",
"['Language'] ['Patron Saint of Liars']\n",
"['Story'] ['Kiss Kiss, Bang Bang']\n",
"['Story'] ['Bloodlines']\n",
"['Language'] ['The Sense of an Ending']\n",
"['Story'] ['Heir to the Empire']\n",
"['Story'] [\"How to Shoot Video That Doesn't Suck\"]\n",
"['Story'] ['Dead or Alive']\n",
"['Character'] ['Unlocked']\n",
"['Story'] ['Shock Wave']\n",
"['Story'] ['The Look of Love']\n",
"['Character'] ['Lost Treasure of the Emerald Eye']\n",
"['Language'] ['Matched']\n",
"['Story'] ['Night Reigns']\n",
"['Story'] ['The Limpopo Academy of Private Detection']\n",
"['Story'] ['The Hangman']\n",
"['Character'] ['Finding Ultra']\n",
"['Character'] ['Search Inside Yourself']\n",
"['Language'] ['Harry Potter and the Order of the Phoenix']\n",
"['Setting'] ['Harry Potter and the Prisoner of Azkaban']\n",
"['Character'] ['The Vow']\n",
"['Story'] ['How to Speak and Write Correctly']\n",
"['Character'] ['Antifragile']\n",
"['Character'] ['The Jerusalem Diamond']\n",
"['Story'] ['Unravel Me']\n",
"['Story'] ['The Blood Gospel']\n",
"['Story'] ['Parable of the Sower']\n",
"['Character'] ['A Leaf on the Wind of All Hallows']\n",
"['Story'] ['Insanity of God']\n",
"['Story']"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" ['Unseen']\n",
"['Character'] ['The Best American Travel Writing 2013']\n",
"['Character'] ['Halfway There']\n",
"['Language'] ['Kramer vs. Kramer']\n",
"['Story'] ['Dirty Wars']\n",
"['Character'] ['Schoolhouse Mystery']\n",
"['Character'] ['Sisterland']\n",
"['Story'] ['Sea Glass Island']\n",
"['Language'] ['Complete Me']\n",
"['Character'] [\"Someone Else's Love Story\"]\n",
"['Story'] ['Influencer']\n",
"['Story'] ['Aftershock']\n",
"['Language'] ['Story of O']\n",
"['Character'] ['The Reason I Jump']\n",
"['Story'] ['Three Little Words']\n",
"['Language'] ['Full Catastrophe Living (Revised Edition)']\n",
"['Character'] ['Sometimes a Rogue']\n",
"['Story'] ['The Hero']\n",
"['Character'] [\"Written in My Own Heart's Blood\"]\n",
"['Character'] ['Busted']\n",
"['Character'] ['The Heiress Effect']\n",
"['Setting'] ['The Rubber Band/The Red Box 2-in-1']\n",
"['Story'] ['White Hot Kiss']\n",
"['Character'] ['Blackmoore']\n",
"['Language'] ['Into the Deep']\n",
"['Character'] ['People I Want to Punch in the Throat']\n",
"['Character'] ['Taking the Lead']\n",
"['Story'] ['Night of the Hunter']\n",
"['Character'] ['Duty']\n",
"['Story'] ['Forget Me Not']\n",
"['Story'] ['The Heist']\n",
"['Setting'] ['The Adventures of Henry Thoreau']\n",
"['Story']"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" ['The Perfect Affair']\n",
"['Character'] ['White Lace and Promises']\n",
"['Character'] ['GI Brides']\n",
"['Language'] ['Fire and Ice']\n",
"['Story'] [\"A Man's Promise\"]\n",
"['Story'] ['Uncaged']\n",
"['Story'] ['Hold the Dream']\n",
"['Setting'] ['Cast in Flame']\n",
"['Story'] ['A New Dawn']\n",
"['Story'] ['Uncovering Her Nine Month Secret']\n",
"['Language'] ['One of Ours']\n",
"['Language'] ['Business Adventures']\n",
"['Story'] ['Night Moves']\n",
"['Story'] ['The Girl of His Dreams']\n",
"['Setting'] ['A Very Levet Christmas']\n",
"['Story'] ['The Bridal Path: Danielle']\n",
"['Story'] ['Mitosis']\n",
"['Story'] ['Indigo Slam']\n",
"['Character'] ['The Joy of Sex']\n",
"['Story'] ['The Time Keeper']\n",
"['Story'] ['Diamonds are Forever']\n",
"['Setting'] ['Lord John and the Private Matter']\n",
"['Story'] ['Time of Attack']\n",
"['Character'] ['The Real Thing']\n",
"['Character'] ['You Are Your Own Gym']\n",
"['Story'] ['The Shade of the Moon']\n",
"['Setting'] ['Fingerprints of the Gods']\n",
"['Story'] ['The Ruins of Gorlan']\n",
"['Story'] ['Divergent']\n",
"['Story'] ['If the Shoe Kills']\n",
"['Character'] ['The Passionate Love of a Rake']\n",
"['Story'] ['The Struggle']\n",
"['Story']"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" ['Deadly Obsession']\n",
"['Story'] ['The Cartel']\n",
"['Story'] ['Whatever It Takes']\n",
"['Character'] ['In the Garden of Beasts']\n",
"['Language'] ['All the Truth Is Out']\n",
"['Character'] ['The Book of Unknown Americans']\n",
"['Story'] ['Winners']\n",
"['Character'] ['To Heaven and Back']\n",
"['Story'] ['Generation 18']\n",
"['Setting'] ['Foundation and Earth']\n",
"['Character'] ['The Paleo Diet']\n",
"['Setting'] ['The Winter Sea']\n",
"['Character'] ['Darkly Dreaming Dexter']\n",
"['Setting'] ['An Oath of Brothers']\n",
"['Setting'] ['The Ocean at the End of the Lane']\n",
"['Story'] ['The 21 Irrefutable Laws of Leadership']\n",
"['Story'] ['Fire and Ice']\n",
"['Story'] ['Run for Your Life']\n",
"['Language'] ['Grand Sophy']\n",
"['Setting'] ['Guilty Pleasures']\n",
"['Story'] ['Skinny Bitch']\n",
"['Character'] ['The Paris Wife']\n",
"['Story'] ['Sheet Music']\n",
"['Character'] ['Mother Night']\n",
"['Language'] ['Moth to a Flame']\n",
"['Story'] ['Fifty Shades of Grey']\n",
"['Character'] ['The End of Your Life Book Club']\n",
"['Character'] ['The Dog Lived (and So Will I)']\n",
"['Story']"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" ['Anything But Sweet']\n",
"['Setting'] ['Hollow City']\n",
"['Character'] ['The Substitute Millionaire']\n",
"['Story'] ['Bare It All']\n",
"['Character'] ['Wait for You']\n",
"['Story'] ['High Heat']\n",
"['Story'] ['That Wintry Feeling']\n",
"['Character'] ['Adultery']\n",
"['Story'] ['The Christmas Bouquet']\n",
"['Character'] ['Jab, Jab, Jab, Right Hook']\n",
"['Character'] ['My Perfect Pantry']\n",
"['Story'] ['Starlight']\n",
"['Setting'] ['I, Robot']\n",
"['Setting'] ['Foundation and Empire']\n",
"['Story'] ['Voyager']\n",
"['Story'] ['Devil in Winter']\n",
"['Story'] ['Darkfever']\n",
"['Story'] ['Dead to the World']\n",
"['Character'] ['Generation Kill']\n",
"['Setting'] ['Point of Impact']\n",
"['Story'] ['A Bend in the Road']\n",
"['Story'] ['Simple Genius']\n",
"['Character'] ['Making Money']\n",
"['Character'] ['Case Histories']\n",
"['Story'] ['Haunted Castle on Hallows Eve']\n",
"['Story'] ['Double Cross']\n",
"['Story'] ['7th Heaven']\n",
"['Language'] ['Beloved']\n",
"['Character'] ['In the Woods']\n",
"['Story'] ['Eye of the Needle']\n",
"['Character'] ['I Am the Messenger']\n",
"['Character'] ['Fooled by Randomness']\n",
"['Character']"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" ['Journey of Souls']\n",
"['Story'] ['Destined For an Early Grave']\n",
"['Story'] ['Wild Heat']\n",
"['Character'] ['The Talent Code']\n",
"['Story'] ['Gone']\n",
"['Setting'] ['Branded as Trouble']\n",
"['Story'] ['Shoulda Been a Cowboy']\n",
"['Character'] ['Half the Sky']\n",
"['Story'] ['Sizzle']\n",
"['Character'] ['Before I Fall']\n",
"['Story'] ['The Street Lawyer']\n",
"['Character'] ['The Warmth of Other Suns']\n",
"['Language'] ['Torment']\n",
"['Story'] ['Kissing Steel']\n",
"['Story'] ['The Search']\n",
"['Story'] ['Savor the Moment']\n",
"['Story'] [\"Sunny Chandler's Return\"]\n",
"['Story'] ['Darker Than Night']\n",
"['Setting'] ['A Fine Balance']\n",
"['Story'] ['Finding Perfect']\n",
"['Language'] ['The Elegance of the Hedgehog']\n",
"['Story'] ['The Heir']\n",
"['Character'] ['Racing in the Rain']\n",
"['Story'] ['Left Behind']\n",
"['Character'] ['The Lost Boy']\n",
"['Setting'] ['The Snowman']\n",
"['Story'] ['Never Buried']\n",
"['Story'] ['Highland Heat']\n",
"['Character'] ['The Autobiography of Mrs. Tom Thumb']\n",
"['Setting'] ['Ready Player One']\n",
"['Character'] ['Quiet']\n",
"['Setting'] ['The Caves of Steel']\n",
"['Story']"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" [\"Apple Turnover Murder Bundle with Key Lime Pie Murder, Cherry Cheesecake Murder, Lemon Meringue Pie Murder, and an EXTENDED excerpt of Devil's Food Cake Murder\"]\n",
"['Story'] ['The Secret']\n",
"['Story'] ['Dark Force Rising']\n",
"['Story'] ['The Heart of Devin MacKade']\n",
"['Character'] ['Women, Race, & Class']\n",
"['Setting'] ['The Cay']\n",
"['Story'] [\"Red's Hot Cowboy\"]\n",
"['Character'] ['Why Nations Fail']\n",
"['Story'] ['Second Son']\n",
"['Story'] ['Fury']\n",
"['Character'] ['Wild']\n",
"['Language'] ['Death Comes to Pemberley']\n",
"['Story'] ['Bear Meets Girl']\n",
"['Story'] ['La Mortal Amada de Samson']\n",
"['Character'] ['How Will You Measure Your Life?']\n",
"['Story'] ['Damage Control']\n",
"['Character'] ['Grace']\n",
"['Setting'] ['The Twelve']\n",
"['Character'] ['Every Day']\n",
"['Language'] ['Fifty Shades Freed']\n",
"['Story'] ['Fear the Darkness']\n",
"['Setting'] ['Jurassic Park']\n",
"['Story'] ['Snatched']\n",
"['Story'] ['If You Were Mine']\n",
"['Story'] ['Blood of Dragons']\n",
"['Story'] ['The Rose of Fire']\n",
"['Story'] ['Pet Shop Boys']\n",
"['Setting'] ['Nine Tailors']\n",
"['Language'] ['Dirty']\n",
"['Story'] ['Ella Enchanted']\n",
"['Story'] ['Instant Attraction']\n",
"['Character'] ['We Were Soldiers Once . . . and Young']\n",
"['Character'] ['Jumpstart to Skinny']\n",
"['Character']"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" ['Going Clear']\n",
"['Character'] ['The Best Man']\n",
"['Setting'] ['The Litter of the Law']\n",
"['Story'] ['Wish List']\n",
"['Story'] ['Heartsong']\n",
"['Language'] ['The Newcomer']\n",
"['Story'] ['Envy']\n",
"['Character'] ['All In']\n",
"['Character'] ['The Godborn']\n",
"['Story'] [\"I Can't Take It!\"]\n",
"['Story'] ['Classified']\n",
"['Story'] ['Going Once']\n",
"['Character'] ['Exposed']\n",
"['Character'] ['Big Nate Makes a Splash']\n",
"['Story'] ['The Kill Switch']\n",
"['Character'] ['Making Sense of the Bible']\n",
"['Character'] ['Burn the Fat, Feed the Muscle']\n",
"['Character'] ['The Way You Look Tonight']\n",
"['Language'] ['Wyoming Bold']\n",
"['Setting'] ['Forget Me Knot']\n",
"['Character'] ['5 Love Languages Singles Edition']\n",
"['Character'] ['100 Days of Real Food']\n",
"['Story'] [\"Shawn O'Brien Town Tame\"]\n",
"['Character'] ['Knock Out']\n",
"['Story'] ['Waking Up Pregnant']\n",
"['Story'] ['Bite Me']\n",
"['Language'] ['Love With a Perfect Cowboy']\n",
"['Story'] ['The Sweet Spot']\n",
"['Character'] ['Essentialism']\n",
"['Story'] ['Lord Peter Wimsey Mysteries, Volumes One through Three']\n",
"['Character'] ['Red at Night']\n",
"['Story'] ['King Cave']\n",
"['Story'] [\"The Assassin's Blade\"]\n",
"['Character']"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" [\"The Sleepwalker's Guide to Dancing\"]\n",
"['Story'] ['A Perfect Life']\n",
"['Character'] ['The Blue Book of Grammar and Punctuation']\n",
"['Language'] ['A Wedding in Provence']\n",
"['Language'] [\"The Earl's Mistress\"]\n",
"['Character'] ['No Strings Attached']\n",
"['Story'] ['Never Say Die']\n",
"['Character'] ['The Microbiome Diet']\n",
"['Character'] ['Stone Mattress']\n",
"['Character'] ['Rose Gold']\n",
"['Language'] ['The Zone of Interest']\n",
"['Story'] [\"I'm the Man\"]\n",
"['Story'] ['The Collapse of Western Civilization']\n",
"['Character'] ['Maybe This Time']\n",
"['Setting'] ['The Roosevelts']\n",
"['Language'] ['White Bird in a Blizzard']\n",
"['Character'] ['The Hidden Blade']\n",
"['Language'] ['The Painter']\n",
"['Story'] ['Exile']\n",
"['Story'] ['Without Fail']\n",
"['Character'] ['Tribal Leadership']\n",
"['Character'] ['Fives and Twenty-Fives']\n",
"['Language'] ['The Burgess Boys']\n",
"['Character'] ['The Kite Runner']\n",
"['Character'] ['Influence']\n",
"['Setting'] ['The Dark Monk']\n",
"['Character'] ['Heat of Passion']\n",
"['Story'] ['Fatal Justice: Book Two of the Fatal Series']\n",
"['Language'] ['Everybody Writes']\n",
"['Character'] ['Peace from Broken Pieces']\n",
"['Story'] ['21 Days to Improve Communicating with Your Angels']\n",
"['Character'] ['The Joy Luck Club (SparkNotes)']\n",
"['Story'] ['Roses Are Red']\n",
"['Character']"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" ['Lies My Teacher Told Me']\n",
"['Story'] ['The Vampire Lestat']\n",
"['Character'] ['The Christmas Wedding Ring']\n",
"['Story'] ['An Abundance of Katherines']\n",
"['Character'] ['Mountains Beyond Mountains']\n",
"['Story'] ['Under the Olive Tree']\n",
"['Setting'] [\"Sharpe's Tiger\"]\n",
"['Language'] ['Paradise Valley']\n",
"['Story'] ['The Seduction of Emily']\n",
"['Story'] ['City of Bones']\n",
"['Setting'] ['Lord John and the Brotherhood of the Blade']\n",
"['Character'] [\"It's Your Ship\"]\n",
"['Story'] ['Black Sheep']\n",
"['Character'] ['The Hunger Games']\n",
"['Story'] ['Fantasy in Death']\n",
"['Story'] ['Gregor and the Curse of the Warmbloods']\n",
"['Character'] ['A Brief History of Time']\n",
"['Character'] ['We Need to Talk About Kevin']\n",
"['Character'] ['The Wedding']\n",
"['Story'] ['Killing the Blues']\n",
"['Character'] ['America the Beautiful']\n",
"['Character'] [\"The Nazi Officer's Wife\"]\n",
"['Character'] ['To Marry an English Lord']\n",
"['Character'] ['Never Too Late']\n",
"['Character'] ['First Love']\n",
"['Story'] ['Something Wicked']\n",
"['Story'] ['The Rebound Girl']\n",
"['Character'] ['Rules']\n",
"['Story'] ['The Forgetful Bride']\n",
"['Story'] ['Just One Night']\n",
"['Character'] ['The Pearl that Broke Its Shell']\n",
"['Character'] ['Lying']\n",
"['Setting'] ['Crochet Stitch Dictionary']\n",
"['Language']"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
" ['The Storied Life of A. J. Fikry']\n",
"['Setting'] ['Half a King']\n",
"['Story'] ['End Game']\n",
"['Character'] ['Rare Bird']\n",
"['Story'] ['Pride and Pleasure']\n",
"['Story'] ['Spectrum']\n",
"['Language'] ['Everything Beautiful Began After']\n"
]
}
],
"prompt_number": 14
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment