{ "cells": [ { "cell_type": "markdown", "id": "7b4f91a3", "metadata": {}, "source": [ "# Lab 05\n", "\n", "1.\tFile=\"https://raw.githubusercontent.com/masterfloss/text/main/dream.txt\"\n", "2.\tRead the file.\n", "3.\tWhat is the sentiment of the text? Suggestions use Vader and Textblob libraries\n", "4.\tHow does the sentiment evolve over the text? Suggestions use Vader and Textblob libraries \n", "5.\tWhat are the most frequent words (without removing stopwords)\n", "6.\tWhat are the most frequent words (removing stopwords)\n", "\n", "probably, you will need to install several libraries." ] }, { "cell_type": "code", "execution_count": null, "id": "18449717", "metadata": {}, "outputs": [], "source": [ "# import libraries\n", "import pandas as pd\n", "import nltk\n", "from nltk.tokenize import RegexpTokenizer\n", "from nltk.sentiment.vader import SentimentIntensityAnalyzer\n", "from nltk.corpus import stopwords\n", "import matplotlib.pyplot as plt\n", "import requests\n", "# other libraries may be imported" ] }, { "cell_type": "code", "execution_count": null, "id": "31467057", "metadata": {}, "outputs": [], "source": [ "file=\"https://raw.githubusercontent.com/masterfloss/text/main/dream.txt\"\n", "response = requests.get(file)\n", "text=response.text" ] }, { "cell_type": "code", "execution_count": null, "id": "d2b431ec", "metadata": {}, "outputs": [], "source": [ "nltk.download('stopwords')" ] }, { "cell_type": "code", "execution_count": null, "id": "313fdb67", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "1f00e4d5", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.7" } }, "nbformat": 4, "nbformat_minor": 5 }