diff --git a/Quotes Web App/QuoteApp.py b/Quotes Web App/QuoteApp.py new file mode 100644 index 0000000..9f1d25c --- /dev/null +++ b/Quotes Web App/QuoteApp.py @@ -0,0 +1,147 @@ +from flask import Flask, render_template, request, url_for, Markup +import os +import pandas as pd +import numpy as np +from random import randrange + +import nltk +nltk.download('vader_lexicon') + +from nltk.sentiment.vader import SentimentIntensityAnalyzer + +app = Flask(__name__) + +# load quotes in memory +BASE_DIR = os.path.dirname(os.path.abspath(__file__)) + +# declare global variable +quotes = None + + +@app.before_request +def prepare_sentiment_quote_stash(): + global quotes + + # load the quote stash + quotes = pd.read_csv(os.path.join(BASE_DIR, 'quotes.csv')) + + sid = SentimentIntensityAnalyzer() + + all_compounds = [] + for sentence in quotes['quote']: + ss = sid.polarity_scores(sentence) + for k in sorted(ss): + if k == 'compound': + all_compounds.append(ss[k]) + + + # add sentiment to the data + quotes['sentiment_score'] = all_compounds + + # create ladder index + quotes = quotes.sort_values('sentiment_score') + quotes['index'] = [ix for ix in range(0, len(quotes))] + + + +def gimme_a_quote(direction = None, current_index = None, max_index_value = 0): + rand_index = randrange(max_index_value) + darker = None + brighter = None + + + # New session visit + if current_index is None: + brighter = rand_index + + if direction == 'brighter': + brighter = current_index + else: + darker = current_index + + if darker is not None: + try: + current_index = int(darker) + except ValueError: + # somebody is gaming the system + current_index = rand_index + + + if current_index > 0: + # try for a lesser value than current one + rand_index = randrange(0, current_index) + else: + # already at lowest point so assign a new random of full set + rand_index = rand_index + + + elif brighter is not None: + try: + current_index = int(brighter) + except ValueError: + # somebody is gaming the system + current_index = rand_index + + # try for a higher value than current one + if current_index < max_index_value -1: + rand_index = randrange(current_index, max_index_value) + else: + # already at highest point so assign a new random of full set + rand_index = rand_index + else: + # grab a random value + rand_index = rand_index + + return (rand_index) + + +@app.route("/") +def quote_me(): + quote_stash_tmp = quotes.copy() + max_index_value = np.max(quote_stash_tmp['index'].values) + rand_index_value = randrange(max_index_value) + + darker = request.args.get("darker") + brighter = request.args.get("brighter") + + if darker is not None: + + try: + current_index = int(darker) + except ValueError: + # somebody is gaming the system + current_index = randrange(max_index_value) + + new_index = gimme_a_quote(direction = 'darker', current_index = current_index, max_index_value = max_index_value) + + elif brighter is not None: + + try: + current_index = int(brighter) + except ValueError: + # somebody is gaming the system + current_index = rand_index_value + + new_index = gimme_a_quote(direction = 'brighter', current_index = current_index, max_index_value = max_index_value) + + + else: + # grab a random value + new_index = randrange(max_index_value) + + random_quote = quote_stash_tmp.iloc[new_index] + + + # get a random integer between 0 and max_index_value + quote=random_quote['quote'] + author = random_quote['author'] + current_id = random_quote['index'] + + return render_template("quote.html", + quote=quote, + author=author, + current_id=current_id,) + + +if __name__ == '__main__': + app.run() diff --git a/Quotes Web App/QuoteWebApp.ipynb b/Quotes Web App/QuoteWebApp.ipynb new file mode 100644 index 0000000..86b6b97 --- /dev/null +++ b/Quotes Web App/QuoteWebApp.ipynb @@ -0,0 +1,1681 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "QuoteWebApp", + "provenance": [], + "collapsed_sections": [] + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + } + }, + "cells": [ + { + "cell_type": "code", + "metadata": { + "id": "2t1a8MWjSDSD", + "colab_type": "code", + "colab": {} + }, + "source": [ + "import pandas as pd\n", + "import numpy as np" + ], + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "oWR70jAjStJW", + "colab_type": "code", + "outputId": "1a664ceb-3604-4b95-939f-c87e903b80b2", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 204 + } + }, + "source": [ + "quotes = pd.read_csv('quote_data.csv')\n", + "quotes.head()" + ], + "execution_count": 24, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
quoteauthor
0Pain is inevitable, but misery is optional.Tim Hansel
1To avoid criticism, do nothing, say nothing, b...Elbert Hubbard
2Believe and act as if it were impossible to fail.Charles Kettering
3Never get out of the boat. Absolutely goddamn ...Captain Willard
4Nobody can make you feel inferior without your...Eleanor Roosevelt
\n", + "
" + ], + "text/plain": [ + " quote author\n", + "0 Pain is inevitable, but misery is optional. Tim Hansel\n", + "1 To avoid criticism, do nothing, say nothing, b... Elbert Hubbard\n", + "2 Believe and act as if it were impossible to fail. Charles Kettering\n", + "3 Never get out of the boat. Absolutely goddamn ... Captain Willard\n", + "4 Nobody can make you feel inferior without your... Eleanor Roosevelt" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 24 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "G8oKA_w4S2vX", + "colab_type": "code", + "outputId": "43e4b151-4ddc-45f7-c9f5-972556d035f2", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 204 + } + }, + "source": [ + "quotes = quotes.drop_duplicates(subset='quote', keep='last')\n", + "quotes.head()" + ], + "execution_count": 25, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
quoteauthor
0Pain is inevitable, but misery is optional.Tim Hansel
1To avoid criticism, do nothing, say nothing, b...Elbert Hubbard
2Believe and act as if it were impossible to fail.Charles Kettering
3Never get out of the boat. Absolutely goddamn ...Captain Willard
4Nobody can make you feel inferior without your...Eleanor Roosevelt
\n", + "
" + ], + "text/plain": [ + " quote author\n", + "0 Pain is inevitable, but misery is optional. Tim Hansel\n", + "1 To avoid criticism, do nothing, say nothing, b... Elbert Hubbard\n", + "2 Believe and act as if it were impossible to fail. Charles Kettering\n", + "3 Never get out of the boat. Absolutely goddamn ... Captain Willard\n", + "4 Nobody can make you feel inferior without your... Eleanor Roosevelt" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 25 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "rwhSCux9T6Ov", + "colab_type": "code", + "outputId": "e61547eb-83b4-49ea-863e-f3a5a884b32f", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + } + }, + "source": [ + "quotes.shape" + ], + "execution_count": 26, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "(108, 2)" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 26 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "gDBgqe0vUABr", + "colab_type": "code", + "colab": {} + }, + "source": [ + "quotes.to_csv('quotes.csv',index=None)" + ], + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "pKGS4yrOX9am", + "colab_type": "code", + "outputId": "7317fa8f-c29a-4488-fb3b-100ff259fb64", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 68 + } + }, + "source": [ + "import nltk\n", + "nltk.download('vader_lexicon')" + ], + "execution_count": 28, + "outputs": [ + { + "output_type": "stream", + "text": [ + "[nltk_data] Downloading package vader_lexicon to /root/nltk_data...\n", + "[nltk_data] Package vader_lexicon is already up-to-date!\n" + ], + "name": "stdout" + }, + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "True" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 28 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "Xz7T_XIYUNDH", + "colab_type": "code", + "outputId": "f7832b93-f21a-4086-b949-db9e42b39bd0", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 1000 + } + }, + "source": [ + "from nltk.sentiment.vader import SentimentIntensityAnalyzer\n", + "analyzer = SentimentIntensityAnalyzer()\n", + "\n", + "all_compounds = []\n", + "for sentence in quotes['quote']:\n", + " print(sentence)\n", + " sentimentscore = analyzer.polarity_scores(sentence)\n", + " for k in sorted(sentimentscore):\n", + " print('{}: {}'.format(k, sentimentscore[k]), end='')\n", + " print()\n", + "\n", + " if k == 'compound':\n", + " all_compounds.append(sentimentscore[k])" + ], + "execution_count": 29, + "outputs": [ + { + "output_type": "stream", + "text": [ + "Pain is inevitable, but misery is optional.\n", + "compound: -0.802\n", + "neg: 0.59\n", + "neu: 0.41\n", + "pos: 0.0\n", + "To avoid criticism, do nothing, say nothing, be nothing.\n", + "compound: -0.6249\n", + "neg: 0.421\n", + "neu: 0.579\n", + "pos: 0.0\n", + "Believe and act as if it were impossible to fail.\n", + "compound: -0.5423\n", + "neg: 0.28\n", + "neu: 0.72\n", + "pos: 0.0\n", + "Never get out of the boat. Absolutely goddamn right. Unless you were goin' all the way.\n", + "compound: -0.5256\n", + "neg: 0.184\n", + "neu: 0.816\n", + "pos: 0.0\n", + "Nobody can make you feel inferior without your consent.\n", + "compound: -0.5213\n", + "neg: 0.384\n", + "neu: 0.616\n", + "pos: 0.0\n", + "What we fear doing most is usually what we most need to do.\n", + "compound: -0.4939\n", + "neg: 0.211\n", + "neu: 0.789\n", + "pos: 0.0\n", + "Everything you’ve ever wanted is on the other side of fear.\n", + "compound: -0.4939\n", + "neg: 0.242\n", + "neu: 0.758\n", + "pos: 0.0\n", + "Success is going from failure to failure without losing your enthusiasm.\n", + "compound: -0.4805\n", + "neg: 0.431\n", + "neu: 0.287\n", + "pos: 0.282\n", + "If there is no struggle, there is no progress.\n", + "compound: -0.4404\n", + "neg: 0.462\n", + "neu: 0.345\n", + "pos: 0.193\n", + "There are no short cuts to any place worth going.\n", + "compound: -0.3612\n", + "neg: 0.331\n", + "neu: 0.526\n", + "pos: 0.143\n", + "In each business, we have two strands: the day-to-day, and the future group thinking, 'How do I disrupt myself?' The people running it can't be the same ones thinking about its disruption.\n", + "compound: -0.3612\n", + "neg: 0.077\n", + "neu: 0.923\n", + "pos: 0.0\n", + "No person will have occasion to complain of the want of time who never loses any.\n", + "compound: -0.3481\n", + "neg: 0.235\n", + "neu: 0.601\n", + "pos: 0.163\n", + "The most common form of despair is not being who you are.\n", + "compound: -0.3182\n", + "neg: 0.173\n", + "neu: 0.827\n", + "pos: 0.0\n", + "There are no traffic jams along the extra mile.\n", + "compound: -0.296\n", + "neg: 0.216\n", + "neu: 0.784\n", + "pos: 0.0\n", + "Do it trembling if you must, but do it!\n", + "compound: -0.2598\n", + "neg: 0.203\n", + "neu: 0.797\n", + "pos: 0.0\n", + "Money is, in some respects, like fire. It is a very excellent servant, but a terrible master.\n", + "compound: -0.2391\n", + "neg: 0.269\n", + "neu: 0.46\n", + "pos: 0.271\n", + "If you don't go after what you want, you'll never have it. If you don't ask, the answer is always no. If you don't step forward, you're always in the same place.\n", + "compound: -0.2263\n", + "neg: 0.066\n", + "neu: 0.896\n", + "pos: 0.039\n", + "And it is awfully hard to come up with those ideas if you don't have any time to think.\n", + "compound: -0.1761\n", + "neg: 0.086\n", + "neu: 0.914\n", + "pos: 0.0\n", + "You miss 100% of the shots you don’t take.\n", + "compound: -0.1531\n", + "neg: 0.167\n", + "neu: 0.833\n", + "pos: 0.0\n", + "Every next level of your life will demand a different version of you.\n", + "compound: -0.128\n", + "neg: 0.12\n", + "neu: 0.88\n", + "pos: 0.0\n", + "Every strike brings me closer to the next home run.\n", + "compound: -0.128\n", + "neg: 0.143\n", + "neu: 0.857\n", + "pos: 0.0\n", + "Obsessed is just a word the lazy use to describe the dedicated.\n", + "compound: -0.0516\n", + "neg: 0.276\n", + "neu: 0.526\n", + "pos: 0.197\n", + "Be who you are and say what you feel, because those who mind don't matter, and those who matter don't mind.\n", + "compound: -0.0382\n", + "neg: 0.102\n", + "neu: 0.898\n", + "pos: 0.0\n", + "Change your thoughts and you change your world.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "If you aren’t going all the way, why go at all?\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "The dreamers are the saviors of the world.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "One thing modeling taught me is that the spotlight can change everything.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "It’s not whether you get knocked down, it’s whether you get up.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "Very often a change of self is needed more than a change of scene.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "You must do what others don't to achieve what others won't.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "I don't know who my grandfather was; I am much more concerned to know what his grandson will be.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "If you have everything under control, you’re not moving fast enough.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "You've got to bumble forward into the unknown.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "How Everyone you Will Ever Meet Knows Something that You Don't.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "Don’t wait. The time will never be just right.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "Learn from yesterday, live for today, look to tomorrow, rest this afternoon.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "The power of imagination makes us infinite.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "Forever is composed of nows.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "Don’t count the days, make the days count.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "Always make a total effort, even when the odds are against you.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "If you can’t outplay them, outwork them.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "When you come to a roadblock, take a detour.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "Believe you can and you’re halfway there.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "Do what you can, where you are, with what you have.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "Even if you’re on the right track, you’ll get run over if you just sit there.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "Life is 10% what happens to you and 90% how you react to it.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "Life's simple. You make choices and you don't look back.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "Light tomorrow with today.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "I will go anywhere as long as it is forward.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "The difference between ordinary and extraordinary is that little extra.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "Don't live the same day over and over again and call that a life.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "When you talk, you are only repeating what you already know. But if you listen, you may learn something new.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "If you have some power, then your job is to empower somebody else.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "It is never too late to be what you might have been.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "The price of anything is the amount of life you exchange for it.\n", + "compound: 0.0\n", + "neg: 0.0\n", + "neu: 1.0\n", + "pos: 0.0\n", + "It does not do to leave a live dragon out of your calculations, if you live near him.\n", + "compound: 0.0382\n", + "neg: 0.0\n", + "neu: 0.933\n", + "pos: 0.067\n", + "Tough times never last, but tough people do.\n", + "compound: 0.0785\n", + "neg: 0.142\n", + "neu: 0.681\n", + "pos: 0.177\n", + "The more I want to get something done, the less I call it work.\n", + "compound: 0.1513\n", + "neg: 0.0\n", + "neu: 0.874\n", + "pos: 0.126\n", + "A person who is nice to you, but rude to the waiter, is not a nice person.\n", + "compound: 0.1531\n", + "neg: 0.185\n", + "neu: 0.556\n", + "pos: 0.259\n", + "It does not matter how slowly you go as long as you do not stop.\n", + "compound: 0.2057\n", + "neg: 0.067\n", + "neu: 0.814\n", + "pos: 0.118\n", + "Try not. Do, or do not. There is no try.\n", + "compound: 0.2235\n", + "neg: 0.0\n", + "neu: 0.827\n", + "pos: 0.173\n", + "Our dreams feel real while we're in them. It's only when we wake we realize things were strange\n", + "compound: 0.2263\n", + "neg: 0.088\n", + "neu: 0.78\n", + "pos: 0.132\n", + "The gateway skill to good time management is when you ask not just what you need to do, but how long it will take.\n", + "compound: 0.2382\n", + "neg: 0.0\n", + "neu: 0.922\n", + "pos: 0.078\n", + "Life is not a problem to be solved, but a reality to be experienced.\n", + "compound: 0.2912\n", + "neg: 0.0\n", + "neu: 0.759\n", + "pos: 0.241\n", + "Every moment is a fresh beginning.\n", + "compound: 0.3182\n", + "neg: 0.0\n", + "neu: 0.635\n", + "pos: 0.365\n", + "Waking up this morning, I smile. 24 brand new hours are before me. I vow to live fully in each moment.\n", + "compound: 0.3612\n", + "neg: 0.0\n", + "neu: 0.878\n", + "pos: 0.122\n", + "Sell a man a fish, he eats for a day. Teach a man how to fish, you ruin a wonderful business opportunity.\n", + "compound: 0.4019\n", + "neg: 0.156\n", + "neu: 0.576\n", + "pos: 0.267\n", + "You must be the change you wish to see in the world.\n", + "compound: 0.4019\n", + "neg: 0.0\n", + "neu: 0.803\n", + "pos: 0.197\n", + "A year from now you may wish you had started today.\n", + "compound: 0.4019\n", + "neg: 0.0\n", + "neu: 0.769\n", + "pos: 0.231\n", + "If you don’t build your dreams, someone will hire you to build theirs.\n", + "compound: 0.4019\n", + "neg: 0.0\n", + "neu: 0.816\n", + "pos: 0.184\n", + "You must be the person you have never had the courage to be. Gradually, you will discover that you are that person, but until you can see this clearly, you must pretend and invent.\n", + "compound: 0.4163\n", + "neg: 0.088\n", + "neu: 0.803\n", + "pos: 0.108\n", + "The road to Easy Street goes through the sewer.\n", + "compound: 0.4404\n", + "neg: 0.0\n", + "neu: 0.734\n", + "pos: 0.266\n", + "The harder I work, the luckier I get.\n", + "compound: 0.4404\n", + "neg: 0.0\n", + "neu: 0.633\n", + "pos: 0.367\n", + "Just keep going. Everybody gets better if they keep at it.\n", + "compound: 0.4404\n", + "neg: 0.0\n", + "neu: 0.775\n", + "pos: 0.225\n", + "'What day is it?' asked Pooh. 'It’s today,' squeaked Piglet. 'My favorite day,' said Pooh.\n", + "compound: 0.4588\n", + "neg: 0.0\n", + "neu: 0.824\n", + "pos: 0.176\n", + "The competitor to be feared is one who never bothers about you at all, but goes on making his own business better all the time.\n", + "compound: 0.4671\n", + "neg: 0.072\n", + "neu: 0.752\n", + "pos: 0.176\n", + "People love to buy, they don't like to be sold.\n", + "compound: 0.4749\n", + "neg: 0.147\n", + "neu: 0.559\n", + "pos: 0.294\n", + "Few \"great\" ideas come from an individual; instead, they’re gradually expanded on and improved by a team or network of individuals.\n", + "compound: 0.4767\n", + "neg: 0.0\n", + "neu: 0.86\n", + "pos: 0.14\n", + "It takes courage to grow up and become who you really are.\n", + "compound: 0.4939\n", + "neg: 0.0\n", + "neu: 0.775\n", + "pos: 0.225\n", + "Keep your face to the sunshine and you can never see the shadow.\n", + "compound: 0.4939\n", + "neg: 0.0\n", + "neu: 0.789\n", + "pos: 0.211\n", + "Look at everything always as though you were seeing it either for the first or last time: Thus is your time on earth filled with glory.\n", + "compound: 0.5423\n", + "neg: 0.0\n", + "neu: 0.877\n", + "pos: 0.123\n", + "Don’t downgrade your dream just to fit your reality.\n", + "compound: 0.5423\n", + "neg: 0.0\n", + "neu: 0.609\n", + "pos: 0.391\n", + "The trick is to enjoy life. Don't wish away your days, waiting for better ones ahead.\n", + "compound: 0.5635\n", + "neg: 0.16\n", + "neu: 0.557\n", + "pos: 0.283\n", + "Action is the foundational key to all success.\n", + "compound: 0.5719\n", + "neg: 0.0\n", + "neu: 0.654\n", + "pos: 0.346\n", + "There is only one success: to be able to spend your life in your own way.\n", + "compound: 0.5719\n", + "neg: 0.0\n", + "neu: 0.802\n", + "pos: 0.198\n", + "Life is beautiful, as long as it consumes you.\n", + "compound: 0.5994\n", + "neg: 0.0\n", + "neu: 0.672\n", + "pos: 0.328\n", + "Make each day your masterpiece.\n", + "compound: 0.6249\n", + "neg: 0.0\n", + "neu: 0.494\n", + "pos: 0.506\n", + "Never let your memories be greater than your dreams.\n", + "compound: 0.6369\n", + "neg: 0.0\n", + "neu: 0.574\n", + "pos: 0.426\n", + "Write it on your heart that every day is the best day in the year.\n", + "compound: 0.6369\n", + "neg: 0.0\n", + "neu: 0.769\n", + "pos: 0.231\n", + "The best way to predict the future is to invent it.\n", + "compound: 0.6369\n", + "neg: 0.0\n", + "neu: 0.704\n", + "pos: 0.296\n", + "The best time to plant a tree was twenty years ago, the second-best time is right now.\n", + "compound: 0.6369\n", + "neg: 0.0\n", + "neu: 0.781\n", + "pos: 0.219\n", + "I think laziness is a cardinal sin -- not in the sense that you should always keep busy, but in the sense that if you have the potential to create something that can be useful to others, then you should do everything you can to make it happen.\n", + "compound: 0.6369\n", + "neg: 0.044\n", + "neu: 0.83\n", + "pos: 0.125\n", + "Do what you love and the money will follow.\n", + "compound: 0.6369\n", + "neg: 0.0\n", + "neu: 0.656\n", + "pos: 0.344\n", + "Champions keep playing until they get it right.\n", + "compound: 0.6369\n", + "neg: 0.0\n", + "neu: 0.536\n", + "pos: 0.464\n", + "The best way out is always through.\n", + "compound: 0.6369\n", + "neg: 0.0\n", + "neu: 0.588\n", + "pos: 0.412\n", + "Every morning, I imagine creating a new business that needs to be sold by the end of the day. I better hustle today!\n", + "compound: 0.6588\n", + "neg: 0.0\n", + "neu: 0.769\n", + "pos: 0.231\n", + "The highest profits are made in trades that show a profit right from the start.\n", + "compound: 0.7003\n", + "neg: 0.0\n", + "neu: 0.674\n", + "pos: 0.326\n", + "Fact is, no one cares about your marketing goals. But everyone likes a good story.\n", + "compound: 0.7579\n", + "neg: 0.105\n", + "neu: 0.478\n", + "pos: 0.416\n", + "It is much more difficult to judge oneself than to judge others. If you succeed in judging yourself rightly, then you are indeed a man of true wisdom.\n", + "compound: 0.7655\n", + "neg: 0.079\n", + "neu: 0.654\n", + "pos: 0.267\n", + "The first principle is that you must not fool yourself and you are the easiest person to fool.\n", + "compound: 0.7658\n", + "neg: 0.0\n", + "neu: 0.663\n", + "pos: 0.337\n", + "The best dreams happen when you’re awake.\n", + "compound: 0.7845\n", + "neg: 0.0\n", + "neu: 0.42\n", + "pos: 0.58\n", + "Remember that sometimes not getting what you want is a wonderful stroke of luck.\n", + "compound: 0.7906\n", + "neg: 0.0\n", + "neu: 0.556\n", + "pos: 0.444\n", + "I'm sure the universe is full of intelligent life. It's just been too intelligent to come here.\n", + "compound: 0.8074\n", + "neg: 0.0\n", + "neu: 0.628\n", + "pos: 0.372\n", + "Don’t wish it were easier, wish you were better.\n", + "compound: 0.8779\n", + "neg: 0.0\n", + "neu: 0.311\n", + "pos: 0.689\n", + "Out yonder there was this huge world, which exists independently of us human beings and which stands before us like a great, eternal riddle, at least partially accessible to our inspection and thinking. The contemplation of this world beckoned like a liberation…\n", + "compound: 0.8939\n", + "neg: 0.0\n", + "neu: 0.754\n", + "pos: 0.246\n", + "Life is beautiful, so long as it is consuming you. When it is rushing through you, destroying you, life is glorious. It is best to roar away, like a fire with a great draught, white-hot to the last bit.\n", + "compound: 0.9313\n", + "neg: 0.109\n", + "neu: 0.546\n", + "pos: 0.344\n", + "I offer you peace. I offer you love. I offer you friendship. I see your beauty. I hear your need. I feel your feelings.\n", + "compound: 0.9371\n", + "neg: 0.0\n", + "neu: 0.493\n", + "pos: 0.507\n", + "When we are mindful, deeply in touch with the present moment, our understanding of what is going on deepens, and we begin to be filled with acceptance, joy, peace and love.\n", + "compound: 0.9382\n", + "neg: 0.0\n", + "neu: 0.651\n", + "pos: 0.349\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "XDYaKeFCXyw5", + "colab_type": "code", + "colab": {} + }, + "source": [ + "#Compound score -1 for most negative and +1 for most positive\n", + "# positive sentiment: compound score >= 0.05\n", + "# neutral sentiment: compound score > -0.05 and compound score < 0.05\n" + ], + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "lvhQdZK_ZHU3", + "colab_type": "code", + "outputId": "efa6bffc-f976-47d9-d849-66b6dbcb3697", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 187 + } + }, + "source": [ + "all_compounds[:10]" + ], + "execution_count": 30, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "[-0.802,\n", + " -0.6249,\n", + " -0.5423,\n", + " -0.5256,\n", + " -0.5213,\n", + " -0.4939,\n", + " -0.4939,\n", + " -0.4805,\n", + " -0.4404,\n", + " -0.3612]" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 30 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "mmtePZYHZgEi", + "colab_type": "code", + "outputId": "aa0d62a7-9189-4609-adbe-cf984a7cdc1a", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 281 + } + }, + "source": [ + "import matplotlib.pyplot as plt\n", + "plt.plot(sorted(all_compounds))\n", + "plt.title('Overall sentiment in Quotes')\n", + "plt.show()" + ], + "execution_count": 31, + "outputs": [ + { + "output_type": "display_data", + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEICAYAAABS0fM3AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0\ndHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAgAElEQVR4nO3deXxU9b3/8dcnCSHsO8i+CALiAjoC\n1l20om3F9moV6xV7VbpoF1u9au29td72luq9P+1iVVRa64ZWq+LVioKotYoSFAQEJOwEAiTshOyf\n3x/nxI4xYZtJTmbm/Xw85pE563wmJznvOd/vmXPM3RERkcyVFXUBIiISLQWBiEiGUxCIiGQ4BYGI\nSIZTEIiIZDgFgYhIhlMQiIhkOAWBNCtmdruZPRY+H2BmbmY5Edf0NzObFGUNDTGzPWY2KOo6JLUp\nCAQzu8rMFplZqZkVmdl9ZtYx6rqiEB9Etdz9fHd/JIJa/mRmv9jfPO7e1t1XHeb6W5rZr8xsnZnt\nM7MVZnajmdnhVfy59a8xs3OSsS5pXAqCDGdmPwZ+DdwEdADGAv2B18wsN8mvFekne/mcvwDjgAuA\ndsC/At8C/jfKoiQC7q5Hhj6A9sAe4Ot1xrcFtgL/BvQC9gGd46aPAoqBFuHwvwFLge3ATKB/3LwO\nXAesAFaH434DrAd2AfOB0+Lmvx14LHw+IFw+p4H6bwYKgd3AcmBcOD4LuAVYCZQAT9fWH7fOScC6\n8H3cFk4bD1QAleHvZWE4/g3gmvD5VcA/gLuBHcAq4Avh+PXAFmBSXI0tgf8JX2szcD/QKpx2JrAB\n+HG43Cbgm+G0yWEdFWEtLzbwO3BgcPj8T8C9wEvh7+Q94MgGlhsHlAF964wfA1QDg8LhNcA59W2f\ncPhCYEn4u3gDGB6OfxSoIfjb2QP8ezh+LPBOOP9C4My4dV0V/j53A6uBb0T9P5Ip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I5hEwOk/rbcAGxw9/fC4WcIgiGdtuM5\nwGp33+rulcBfCbZtOm3HWg1tt2a7D8qkIJgHDAnPUsgl6KiaEXFNCQnbyh8Glrr7/4ubNAOYFD6f\nBLzQ1LUli7vf6u593H0AwTZ73d2/AcwBLg5nS/X3WASsN7Oh4ahxwMek0XYkaBIaa2atw7/b2veY\nNtsxTkPbbQZwZXj20FhgZ1wTUrTcPWMewAXAJ8BK4Lao60nC+zmV4LDzI2BB+LiAoA19NrACmAV0\njrrWJL3fM4H/C58PAt4HCoC/AC2jri/B9zYSyA+35fNAp3TbjsDPgWXAYuBRoGWqb0fgSYI+j0qC\nI7urG9pugBGcubgSWERwBlXk78HddYkJEZFMl0lNQyIiUg8FgYhIhlMQiIhkOAWBiEiGUxCIiGQ4\nBYGISIZTEIiIZLj/D7ivjavw0pIiAAAAAElFTkSuQmCC\n", + "text/plain": [ + "
" + ] + }, + "metadata": { + "tags": [] + } + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "rIV9l2CwZy5l", + "colab_type": "code", + "outputId": "3285d74f-8e0a-4461-c0ea-54eaf057ab6a", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 204 + } + }, + "source": [ + "quotes['sentimentscore'] = all_compounds\n", + "quotes.head()" + ], + "execution_count": 32, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
quoteauthorsentimentscore
0Pain is inevitable, but misery is optional.Tim Hansel-0.8020
1To avoid criticism, do nothing, say nothing, b...Elbert Hubbard-0.6249
2Believe and act as if it were impossible to fail.Charles Kettering-0.5423
3Never get out of the boat. Absolutely goddamn ...Captain Willard-0.5256
4Nobody can make you feel inferior without your...Eleanor Roosevelt-0.5213
\n", + "
" + ], + "text/plain": [ + " quote ... sentimentscore\n", + "0 Pain is inevitable, but misery is optional. ... -0.8020\n", + "1 To avoid criticism, do nothing, say nothing, b... ... -0.6249\n", + "2 Believe and act as if it were impossible to fail. ... -0.5423\n", + "3 Never get out of the boat. Absolutely goddamn ... ... -0.5256\n", + "4 Nobody can make you feel inferior without your... ... -0.5213\n", + "\n", + "[5 rows x 3 columns]" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 32 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "6_xxBCeWaFyZ", + "colab_type": "code", + "outputId": "7f5653ad-2c21-4c80-bb81-1c09e30adb75", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + } + }, + "source": [ + "minss = np.min(quotes['sentimentscore'])\n", + "maxss = np.max(quotes['sentimentscore'])\n", + "minss, maxss" + ], + "execution_count": 33, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "(-0.802, 0.9382)" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 33 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "Z7hZiWZqacCf", + "colab_type": "code", + "outputId": "9d8eac76-4a3e-48bd-c87a-74ad9b3b6370", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 80 + } + }, + "source": [ + "quotes[quotes['sentimentscore'] == np.min(quotes['sentimentscore'])]" + ], + "execution_count": 34, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
quoteauthorsentimentscore
0Pain is inevitable, but misery is optional.Tim Hansel-0.802
\n", + "
" + ], + "text/plain": [ + " quote author sentimentscore\n", + "0 Pain is inevitable, but misery is optional. Tim Hansel -0.802" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 34 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "9PMuopnZas-x", + "colab_type": "code", + "outputId": "6b0c835c-7ce1-4bde-a1dc-84d2be5a4a5f", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 80 + } + }, + "source": [ + "quotes[quotes['sentimentscore'] == np.max (quotes['sentimentscore'])]" + ], + "execution_count": 35, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
quoteauthorsentimentscore
107When we are mindful, deeply in touch with the ...Thich Nhat Hanh0.9382
\n", + "
" + ], + "text/plain": [ + " quote ... sentimentscore\n", + "107 When we are mindful, deeply in touch with the ... ... 0.9382\n", + "\n", + "[1 rows x 3 columns]" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 35 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "iI0mb1NdbJT4", + "colab_type": "code", + "outputId": "375ef0c3-2d93-4255-9107-31031fa20fb3", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 419 + } + }, + "source": [ + "import numpy as np\n", + "from random import randrange\n", + "from nltk.sentiment.vader import SentimentIntensityAnalyzer\n", + "\n", + "quotes = []\n", + "\n", + "def prepare_sentiment_quotes(quotes_path):\n", + " global quotes\n", + "\n", + " quotes = pd.read_csv(quotes_path)\n", + "\n", + " analyzer = SentimentIntensityAnalyzer()\n", + "\n", + " all_compounds = []\n", + " for sentence in quotes['quote']:\n", + " sentscore = analyzer.polarity_scores(sentence)\n", + " for k in sorted(sentscore):\n", + " if k == 'compound':\n", + " all_compounds.append(sentscore[k])\n", + " \n", + " quotes['sentiment_score'] = all_compounds\n", + "\n", + " quotes = quotes.sort_values('sentiment_score')\n", + " quotes['index'] = [ix for ix in range(0, len(quotes))]\n", + "\n", + " return quotes\n", + "\n", + "prepare_sentiment_quotes('quotes.csv')\n" + ], + "execution_count": 36, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
quoteauthorsentiment_scoreindex
0Pain is inevitable, but misery is optional.Tim Hansel-0.80200
1To avoid criticism, do nothing, say nothing, b...Elbert Hubbard-0.62491
2Believe and act as if it were impossible to fail.Charles Kettering-0.54232
3Never get out of the boat. Absolutely goddamn ...Captain Willard-0.52563
4Nobody can make you feel inferior without your...Eleanor Roosevelt-0.52134
...............
103Don’t wish it were easier, wish you were better.Jim Rohn0.8779103
104Out yonder there was this huge world, which ex...Albert Einstein0.8939104
105Life is beautiful, so long as it is consuming ...D.H. Lawrence0.9313105
106I offer you peace. I offer you love. I offer y...Mahatma Gandhi0.9371106
107When we are mindful, deeply in touch with the ...Thich Nhat Hanh0.9382107
\n", + "

108 rows × 4 columns

\n", + "
" + ], + "text/plain": [ + " quote ... index\n", + "0 Pain is inevitable, but misery is optional. ... 0\n", + "1 To avoid criticism, do nothing, say nothing, b... ... 1\n", + "2 Believe and act as if it were impossible to fail. ... 2\n", + "3 Never get out of the boat. Absolutely goddamn ... ... 3\n", + "4 Nobody can make you feel inferior without your... ... 4\n", + ".. ... ... ...\n", + "103 Don’t wish it were easier, wish you were better. ... 103\n", + "104 Out yonder there was this huge world, which ex... ... 104\n", + "105 Life is beautiful, so long as it is consuming ... ... 105\n", + "106 I offer you peace. I offer you love. I offer y... ... 106\n", + "107 When we are mindful, deeply in touch with the ... ... 107\n", + "\n", + "[108 rows x 4 columns]" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 36 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "4XOEhRvEcbas", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 204 + }, + "outputId": "4aced69e-2157-4266-fe22-63f7375ffaab" + }, + "source": [ + "quotes.head()" + ], + "execution_count": 37, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
quoteauthorsentiment_scoreindex
0Pain is inevitable, but misery is optional.Tim Hansel-0.80200
1To avoid criticism, do nothing, say nothing, b...Elbert Hubbard-0.62491
2Believe and act as if it were impossible to fail.Charles Kettering-0.54232
3Never get out of the boat. Absolutely goddamn ...Captain Willard-0.52563
4Nobody can make you feel inferior without your...Eleanor Roosevelt-0.52134
\n", + "
" + ], + "text/plain": [ + " quote ... index\n", + "0 Pain is inevitable, but misery is optional. ... 0\n", + "1 To avoid criticism, do nothing, say nothing, b... ... 1\n", + "2 Believe and act as if it were impossible to fail. ... 2\n", + "3 Never get out of the boat. Absolutely goddamn ... ... 3\n", + "4 Nobody can make you feel inferior without your... ... 4\n", + "\n", + "[5 rows x 4 columns]" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 37 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "H3EzD-m7hGXc", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 51 + }, + "outputId": "f276c9ba-981f-43e2-daae-91145c3e8284" + }, + "source": [ + "max_ind = np.max(quotes['index'].values)\n", + "\n", + "def starting_quote(direction = None, current_ind=None):\n", + " rand_ind = randrange(max_ind)\n", + " darker = None\n", + " brighter = None\n", + "\n", + " if current_ind is None:\n", + " brighter = rand_ind\n", + "\n", + " if direction == 'brighter':\n", + " brighter = current_ind\n", + " else:\n", + " darker = current_ind\n", + " \n", + " if darker is not None:\n", + " current_ind = rand_ind\n", + "\n", + " try:\n", + " current_ind = int(darker)\n", + " except ValueError:\n", + " current_ind = rand_ind\n", + " \n", + " if current_ind > 0:\n", + " rand_ind = randrange(0, current_ind)\n", + " print('darker')\n", + " else:\n", + " rand_ind =rand_ind\n", + " \n", + " elif brighter is not None:\n", + " # currect_ind = rand_ind\n", + " try:\n", + " current_ind = int(brighter)\n", + " except ValueError:\n", + " current_ind = rand_ind\n", + " \n", + " if current_ind < max_ind-1:\n", + " rand_ind = randrange(current_ind, max_ind)\n", + " print('brighter')\n", + " else:\n", + " rand_ind =rand_ind\n", + " \n", + " else:\n", + " rand_ind = rand_ind\n", + " return rand_ind\n", + "\n", + "starting_quote('darker', 20)" + ], + "execution_count": 39, + "outputs": [ + { + "output_type": "stream", + "text": [ + "darker\n" + ], + "name": "stdout" + }, + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "14" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 39 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "3Na47mmClAqs", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 97 + }, + "outputId": "2ec693e5-0810-4354-b2f1-753340a0c423" + }, + "source": [ + "quotes[quotes['index'] == starting_quote('darker',8)]" + ], + "execution_count": 47, + "outputs": [ + { + "output_type": "stream", + "text": [ + "darker\n" + ], + "name": "stdout" + }, + { + "output_type": "execute_result", + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
quoteauthorsentiment_scoreindex
3Never get out of the boat. Absolutely goddamn ...Captain Willard-0.52563
\n", + "
" + ], + "text/plain": [ + " quote ... index\n", + "3 Never get out of the boat. Absolutely goddamn ... ... 3\n", + "\n", + "[1 rows x 4 columns]" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 47 + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "nSOXSeqiutNu", + "colab_type": "text" + }, + "source": [ + "Now we have every thing we need, lets put this into flask.\n", + "\n" + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "kHkxg77ou2qV", + "colab_type": "code", + "colab": {} + }, + "source": [ + "" + ], + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/Quotes Web App/quotes.csv b/Quotes Web App/quotes.csv new file mode 100644 index 0000000..fd3f5df --- /dev/null +++ b/Quotes Web App/quotes.csv @@ -0,0 +1,109 @@ +quote,author,sentiment_score,index +"Pain is inevitable, but misery is optional.",Tim Hansel,-0.802,0 +"To avoid criticism, do nothing, say nothing, be nothing.",Elbert Hubbard,-0.6249,1 +Believe and act as if it were impossible to fail.,Charles Kettering,-0.5423,2 +Never get out of the boat. Absolutely goddamn right. Unless you were goin' all the way.,Captain Willard,-0.5256,3 +Nobody can make you feel inferior without your consent.,Eleanor Roosevelt,-0.5213,4 +What we fear doing most is usually what we most need to do.,Tim Ferriss,-0.4939,5 +Everything you’ve ever wanted is on the other side of fear.,George Addair,-0.4939,6 +Success is going from failure to failure without losing your enthusiasm.,Winston Churchill,-0.4805,7 +"If there is no struggle, there is no progress.",Frederick Douglass,-0.4404,8 +There are no short cuts to any place worth going.,Beverly Sills,-0.3612,9 +"In each business, we have two strands: the day-to-day, and the future group thinking, 'How do I disrupt myself?' The people running it can't be the same ones thinking about its disruption.",Martin Reeves,-0.3612,10 +No person will have occasion to complain of the want of time who never loses any.,Thomas Jefferson,-0.3481,11 +The most common form of despair is not being who you are.,Kurt Vonnegut,-0.3182,12 +There are no traffic jams along the extra mile.,Roger Staubach,-0.296,13 +"Do it trembling if you must, but do it!",Emmet Fox,-0.2598,14 +"Money is, in some respects, like fire. It is a very excellent servant, but a terrible master.",P. T. Barnum,-0.2391,15 +"If you don't go after what you want, you'll never have it. If you don't ask, the answer is always no. If you don't step forward, you're always in the same place.",Nora Roberts,-0.2263,16 +And it is awfully hard to come up with those ideas if you don't have any time to think.,Paul B. Brown,-0.1761,17 +You miss 100% of the shots you don’t take.,Wayne Gretzky,-0.1531,18 +Every next level of your life will demand a different version of you.,Unknown,-0.128,19 +Every strike brings me closer to the next home run.,Babe Ruth,-0.128,20 +Obsessed is just a word the lazy use to describe the dedicated.,Russell Warren,-0.0516,21 +"Be who you are and say what you feel, because those who mind don't matter, and those who matter don't mind.",Bernard M. Baruch,-0.0382,22 +"When you come to a roadblock, take a detour.",Mary Kay Ash,0.0,23 +Believe you can and you’re halfway there.,Theodore Roosevelt,0.0,24 +"Do what you can, where you are, with what you have.",Teddy Roosevelt,0.0,25 +"Even if you’re on the right track, you’ll get run over if you just sit there.",Will Rogers,0.0,26 +Life is 10% what happens to you and 90% how you react to it.,Charles R. Swindoll,0.0,27 +Life's simple. You make choices and you don't look back.,Han,0.0,28 +I will go anywhere as long as it is forward.,David Livingston,0.0,29 +"If you can’t outplay them, outwork them.",Ben Hogan,0.0,30 +The difference between ordinary and extraordinary is that little extra.,Jimmy Johnson,0.0,31 +Don't live the same day over and over again and call that a life.,Germany Kent,0.0,32 +"When you talk, you are only repeating what you already know. But if you listen, you may learn something new.",The Dalai Lama,0.0,33 +"If you have some power, then your job is to empower somebody else.",Toni Morrison,0.0,34 +The price of anything is the amount of life you exchange for it.,Henry David Thoreau,0.0,35 +Light tomorrow with today.,Elizabeth Barrett Browning,0.0,36 +"Always make a total effort, even when the odds are against you.",Arnold Palmer,0.0,37 +It is never too late to be what you might have been.,George Eliot,0.0,38 +Forever is composed of nows.,Emily Dickinson,0.0,39 +The power of imagination makes us infinite.,John Muir,0.0,40 +"Learn from yesterday, live for today, look to tomorrow, rest this afternoon.",Charles M. Schulz,0.0,41 +Don’t wait. The time will never be just right.,Napoleon Hill,0.0,42 +How Everyone you Will Ever Meet Knows Something that You Don't.,Bill Nye,0.0,43 +You've got to bumble forward into the unknown.,Frank Gehry,0.0,44 +"If you have everything under control, you’re not moving fast enough.",Mario Andretti,0.0,45 +I don't know who my grandfather was; I am much more concerned to know what his grandson will be.,Abraham Lincoln,0.0,46 +You must do what others don't to achieve what others won't.,Les Brown,0.0,47 +Very often a change of self is needed more than a change of scene.,Arthur Christopher Benson,0.0,48 +"It’s not whether you get knocked down, it’s whether you get up.",Vince Lombardi,0.0,49 +One thing modeling taught me is that the spotlight can change everything.,Liya Kebede,0.0,50 +The dreamers are the saviors of the world.,James Allen,0.0,51 +"If you aren’t going all the way, why go at all?",Joe Namath,0.0,52 +"Don’t count the days, make the days count.",Muhammad Ali,0.0,53 +Change your thoughts and you change your world.,Norman Vincent Peale,0.0,54 +"It does not do to leave a live dragon out of your calculations, if you live near him.","J.R.R. Tolkien, The Hobbit or There and Back Again",0.0382,55 +"Tough times never last, but tough people do.",Dr. Robert Schuller,0.0785,56 +"The more I want to get something done, the less I call it work.",Richard Bach,0.1513,57 +"A person who is nice to you, but rude to the waiter, is not a nice person.",Dave Barry,0.1531,58 +It does not matter how slowly you go as long as you do not stop.,Confucius,0.2057,59 +"Try not. Do, or do not. There is no try.",Yoda,0.2235,60 +Our dreams feel real while we're in them. It's only when we wake we realize things were strange,"Cobb, Inception",0.2263,61 +"The gateway skill to good time management is when you ask not just what you need to do, but how long it will take.",Julie Morgenstern,0.2382,62 +"Life is not a problem to be solved, but a reality to be experienced.",Soren Kierkegaard,0.2912,63 +Every moment is a fresh beginning.,T.S. Eliot,0.3182,64 +"Waking up this morning, I smile. 24 brand new hours are before me. I vow to live fully in each moment.",Thich Nhat Hanh,0.3612,65 +"Sell a man a fish, he eats for a day. Teach a man how to fish, you ruin a wonderful business opportunity.",Karl Marx,0.4019,66 +You must be the change you wish to see in the world.,Gandhi,0.4019,67 +A year from now you may wish you had started today.,Karen Lamb,0.4019,68 +"If you don’t build your dreams, someone will hire you to build theirs.",Tony Gaskins,0.4019,69 +"You must be the person you have never had the courage to be. Gradually, you will discover that you are that person, but until you can see this clearly, you must pretend and invent.",Paulo Coelho,0.4163,70 +"The harder I work, the luckier I get.",Gary Player,0.4404,71 +Just keep going. Everybody gets better if they keep at it.,Ted Williams,0.4404,72 +The road to Easy Street goes through the sewer.,John Madden,0.4404,73 +"'What day is it?' asked Pooh. 'It’s today,' squeaked Piglet. 'My favorite day,' said Pooh.",A.A. Milne,0.4588,74 +"The competitor to be feared is one who never bothers about you at all, but goes on making his own business better all the time.",Henry Ford,0.4671,75 +"People love to buy, they don't like to be sold.",Matthew Pollard,0.4749,76 +"Few ""great"" ideas come from an individual; instead, they’re gradually expanded on and improved by a team or network of individuals.",Jayson DeMers,0.4767,77 +It takes courage to grow up and become who you really are.,E.E. Cummings,0.4939,78 +Keep your face to the sunshine and you can never see the shadow.,Helen Keller,0.4939,79 +Don’t downgrade your dream just to fit your reality.,Stuart Scott,0.5423,80 +Look at everything always as though you were seeing it either for the first or last time: Thus is your time on earth filled with glory.,Betty Smith,0.5423,81 +"The trick is to enjoy life. Don't wish away your days, waiting for better ones ahead.",Marjorie Pay Hinckley,0.5635,82 +Action is the foundational key to all success.,Pablo Picasso,0.5719,83 +There is only one success: to be able to spend your life in your own way.,Christopher Morley,0.5719,84 +"Life is beautiful, as long as it consumes you.",Socrates,0.5994,85 +Make each day your masterpiece.,John Wooden,0.6249,86 +Do what you love and the money will follow.,Marsha Sinetar,0.6369,87 +The best way out is always through.,Robert Frost,0.6369,88 +Champions keep playing until they get it right.,Billie Jean King,0.6369,89 +"The best time to plant a tree was twenty years ago, the second-best time is right now.",Chinese Proverb,0.6369,90 +The best way to predict the future is to invent it.,Alan Kay,0.6369,91 +Write it on your heart that every day is the best day in the year.,Ralph Waldo Emerson,0.6369,92 +Never let your memories be greater than your dreams.,Doug Ivester,0.6369,93 +"I think laziness is a cardinal sin -- not in the sense that you should always keep busy, but in the sense that if you have the potential to create something that can be useful to others, then you should do everything you can to make it happen.",François Chollet,0.6369,94 +"Every morning, I imagine creating a new business that needs to be sold by the end of the day. I better hustle today!","Manuel Amuantegui, Finding Motivation in Unusual Places",0.6588,95 +The highest profits are made in trades that show a profit right from the start.,Jesse Livermore,0.7003,96 +"Fact is, no one cares about your marketing goals. But everyone likes a good story.",Shane Snow,0.7579,97 +"It is much more difficult to judge oneself than to judge others. If you succeed in judging yourself rightly, then you are indeed a man of true wisdom.",Antoine de Saint-Exupéry,0.7655,98 +The first principle is that you must not fool yourself and you are the easiest person to fool.,Richard Feynman,0.7658,99 +The best dreams happen when you’re awake.,Cherie Gilderbloom,0.7845,100 +Remember that sometimes not getting what you want is a wonderful stroke of luck.,Dalai Lama,0.7906,101 +I'm sure the universe is full of intelligent life. It's just been too intelligent to come here.,Arthur C. Clarke,0.8074,102 +"Don’t wish it were easier, wish you were better.",Jim Rohn,0.8779,103 +"Out yonder there was this huge world, which exists independently of us human beings and which stands before us like a great, eternal riddle, at least partially accessible to our inspection and thinking. The contemplation of this world beckoned like a liberation…",Albert Einstein,0.8939,104 +"Life is beautiful, so long as it is consuming you. When it is rushing through you, destroying you, life is glorious. It is best to roar away, like a fire with a great draught, white-hot to the last bit.",D.H. Lawrence,0.9313,105 +I offer you peace. I offer you love. I offer you friendship. I see your beauty. I hear your need. I feel your feelings.,Mahatma Gandhi,0.9371,106 +"When we are mindful, deeply in touch with the present moment, our understanding of what is going on deepens, and we begin to be filled with acceptance, joy, peace and love.",Thich Nhat Hanh,0.9382,107 diff --git a/Quotes Web App/static/images/hand.png b/Quotes Web App/static/images/hand.png new file mode 100644 index 0000000..4de4953 Binary files /dev/null and b/Quotes Web App/static/images/hand.png differ diff --git a/Quotes Web App/static/images/inspire-header-me.png b/Quotes Web App/static/images/inspire-header-me.png new file mode 100644 index 0000000..6fff991 Binary files /dev/null and b/Quotes Web App/static/images/inspire-header-me.png differ diff --git a/Quotes Web App/static/images/moon.png b/Quotes Web App/static/images/moon.png new file mode 100644 index 0000000..b7759f7 Binary files /dev/null and b/Quotes Web App/static/images/moon.png differ diff --git a/Quotes Web App/static/images/sun.png b/Quotes Web App/static/images/sun.png new file mode 100644 index 0000000..54116a5 Binary files /dev/null and b/Quotes Web App/static/images/sun.png differ diff --git a/Quotes Web App/templates/quote.html b/Quotes Web App/templates/quote.html new file mode 100644 index 0000000..b3be0db --- /dev/null +++ b/Quotes Web App/templates/quote.html @@ -0,0 +1,153 @@ + + +W3.CSS Template + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+
+ {{quote}}


― {{author}} +
+
+ + + + + + + + + +