diff --git a/README.md b/README.md index 770394e..0627276 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,171 @@ ![build-test workflow](https://github.com/DSProjects2024/thronetalk-game-of-thrones-summarizer/actions/workflows/build_test.yml/badge.svg) [![Coverage Status](https://coveralls.io/repos/github/DSProjects2024/thronetalk-game-of-thrones-summarizer/badge.svg)](https://coveralls.io/github/DSProjects2024/thronetalk-game-of-thrones-summarizer) -1. Project type - An Interactive Web Tool -2. Questions of interest - Can we develop a model that can take a given input text and transform it into the style of a chosen Game of Thrones character, maintaining the character's speech patterns, vocabulary, and personality traits? -3. The goal for the project output - - Generating Text based on Character Style given an input dialogue and a character name. -4. Datasets used - - 1. Dialogues for each character - https://www.kaggle.com/datasets/gopinath15/gameofthrones - 2. Character allegiances and relationship data -https://www.kaggle.com/datasets/mylesoneill/game-of-thrones + +![](./thronetalk-game-of-thrones-summarizer/static/thronetalk_title.png) + + + +## Introduction +Welcome to the Game of Thrones Summarizer Git repository! Inspired by the beloved TV series Game of Thrones, this project harnesses the transformative capabilities of OpenAI's GPT-3 model to provide users with succinct yet immersive summaries of their chosen episodes. As fans journey through the repository, they can explore the complexities of character relationships, plot twists, and thematic elements that have made Game of Thrones a cultural phenomenon. The purpose of this summarizer is to offer users a convenient tool for revisiting and analyzing key moments from the series, facilitating deeper engagement and understanding of the intricate narrative threads woven throughout each episode. Whether refreshing their memory, preparing for discussions, or simply reliving the excitement of the show, users can rely on the Game of Thrones Summarizer to unlock new layers of appreciation for the epic saga of Westeros. + +Public Website: **[thronetalk.streamlit.app](https://thronetalk-summarizer.streamlit.app/)** + + +#### Team Members: +| Name | GitHub | Name | GitHub | +|:------:|:------:|:------:|:------:| +| **Abhinav Duvvuri** | *abhinavdv*| **Baisakhi Sarkar** | *baisakhi771* | +| **Raagul Nagendran** | *raaguln* | **Swarali Desai** | *swarali-desai* | + +## Table of Contents +* [Introduction](#introduction) +* [Tasks of Interest](#tasks-of-interest) +* [Repository Structure](#repository-structure) +* [Installation](#installation) + * [Environment](#environment) + * [Data](#data) + * [Application](#application) +* [Examples](#examples) + + +## Tasks of Interest +- **Interactive Visual Homepage**: + - Enables users to select specified seasons and episode ranges to generate the analysis. + - Provides an interactive dashboard showcasing the top characters and their sentiments across the selected episodes. +- **Character Dialogue Analysis**: + - Allows users to explore word clouds illustrating the most frequently used words by each character in the selected episodes. + - Presents sentiment analysis graphs depicting the emotional journey of main characters throughout the narrative, offering insights into character development and thematic resonance. +- **Season/Episode Summarizer**: + - Facilitates comparison between episodes based on various criteria, including dialogue sentiment, character prominence, and thematic elements. + - Offers users a comprehensive overview of the series' evolution and narrative arcs, empowering them to identify patterns and themes across different episodes and seasons. + + + +## Repository Structure +Here is an overview of our project structure: +``` +|--thronetalk-game-of-thrones-summarizer/ +| |--data/ +| | |-- characters_v4.csv +| | |-- episodes_metadata.csv +| | |-- episode_metadata.csv +| | |-- game-of-thrones.csv +| | |-- ouput_dialogues.csv +| | |-- ouput_dialogues.csv +| | |-- Season_Episode_MultiEpisode.csv +| | |-- show_metadata.json +| |--tests/ +| | |-- mock_constants.py +| | |-- mock_functions.py +| | |-- test_app.py +| | |-- test_data_analysis.py +| | |-- test_get_metadata.py +| | |-- test_model.py +| | |-- test_visualization_generator.py +| | |-- __init__.py +| |--utils/ +| | |-- data_analysis.py +| | |-- model.py +| | |-- visualization_generator.py +| | |-- __init__.py +| |--static/ +| | |-- thronetalk_title.png +| |--app.py +|--scripts/ +| |-- data_cleaning.py +| |-- get_metadata.py +| |-- __init__.py +|--docs/ +| |--images/ +| | |--comp_spec_uml.png +| |-- Component Specification.md +| |-- Functional Specification.md +| |--ThroneTalks-TechnologyReview.pptx +|--examples/ +| |--images/ +| | |-- site_navigation_1.png +| | |-- site_navigation_2.png +| | |-- site_navigation_3.png +| | |-- site_navigation_4.png +| |-- README.md +| |-- site_navigation.md +|-- LICENSE +|-- pyproject.toml +|-- environment.yml +|-- requirements.txt + +``` + + +## Installation + +This repository can be cloned locally by running the following `git` command: +```bash +git clone https://github.com/DSProjects2024/thronetalk-game-of-thrones-summarizer.git +``` +Please note that Git is required to run the above command. For instructions on downloading Git, please see [the GitHub guide](https://github.com/git-guides/install-git). + + +### Environment +This application relies on several Python packages with specific version dependencies. Installing these packages may potentially lead to conflicts with existing packages within the workspace. To mitigate this issue, we suggest utilizing `conda` to establish an isolated Python environment containing all essential packages. You can access the list of required packages within the documentation. [`environment.yml`](./environment.yml) file. + +To create the 'thronetalks' conda environment which contains all the required packages to run the app, run these commands: + +```bash +conda env create -f environment.yml +conda activate thronetalks +``` +The second commande activates the specific environemnt. + + +If you want to deactivate this environment in the future, then use the command: +```bash +conda deactivate +``` + +If you want to delete this environment, then use the following command: +```bash +conda remove --name thronetalks --all +``` + + +### Data +The raw data for our project was obtained from two different sources: + +1. Dialogues for each character - https://www.kaggle.com/datasets/gopinath15/gameofthrones +2. Scrapped metadata from IMBD - metadata for the episodes and the show. + +Since all the metadata scraping is one-off and the show has finished airing, we are not expecting to run the scripts again. But we can use the file `scripts/data_cleaning.py` to generate the metadata again. (Note - scraper might fail because of IMDb's efforts to prevent web scraping, you might have to manually debug it and run it in batches of 10 episodes if so). + +Run the following: +```bash +conda activate thronetalks +python ./scripts/data_cleaning.py +python ./scripts/get_metadata.py +conda deactivate +``` +More details can be found [here](./scripts/README.md) and [here](./examples/data.ipynb). + +Details about the data variables can be found [here](./an_analysis_of_nothing/static/data/README.md). + + +### Application +We generated our application through the open-source `streamlit` package. A local application can be generated with the code: +```bash +conda activate thronetalks +streamlit run thronetalk-game-of-thrones-summarizer/app.py +``` +This will pop up a browser window with the functioning web-application. +More details can be found [here](./examples/README.md). + + +## Examples +A video demonstration of our working application can be seen [here](https://drive.google.com/file/d/1ns3LBZTvtw00qaH_RWThXGwe9duF2EDC/view?usp=sharing). + +More details on how to run our code can be found [here](./examples/README.md). + +## Disclaimer +This project is created by fans for fans and is not affiliated with or endorsed by HBO or the creators of Game of Thrones. + +The word cloud generated for each character might include potentially explicit or inappropriate language. diff --git a/examples/README.md b/examples/README.md index 014590b..7f51d2b 100644 --- a/examples/README.md +++ b/examples/README.md @@ -41,7 +41,7 @@ conda remove --name thronetalks --all ### 4. Run the App -The app can be run on the localhost using the following command. +The app can be run on the localhost using the following command. ```bash streamlit run an_analysis_of_nothing/app.py ``` @@ -64,4 +64,4 @@ The app is hosted as a Streamlit app here: **[throne-talk.streamlit.app](https:/ ## Web Application * Click [here](./site_navigation.md) for a website walk-through with text. -* There is also a visual **[Video Demonstration](##insert link here)** for accessibility. \ No newline at end of file +* There is also a visual **[Video Demonstration](https://drive.google.com/file/d/1ns3LBZTvtw00qaH_RWThXGwe9duF2EDC/view?usp=sharing). \ No newline at end of file diff --git a/examples/data.ipynb b/examples/data.ipynb new file mode 100644 index 0000000..8c0ac54 --- /dev/null +++ b/examples/data.ipynb @@ -0,0 +1,622 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 9, + "id": "89a8d54f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + "
" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from IPython.display import HTML\n", + "\n", + "HTML('''\n", + "
''')" + ] + }, + { + "cell_type": "markdown", + "id": "6d8a9247-327f-4dae-8620-7c2c0cfe4c9f", + "metadata": {}, + "source": [ + "## Overview" + ] + }, + { + "cell_type": "markdown", + "id": "53291321", + "metadata": {}, + "source": [ + "We gathered data from Kaggle for the game of thrones TV show. This data has dialogues data for every character in each episode.\n", + "[Dialogues for each character data](https://www.kaggle.com/datasets/gopinath15/gameofthrones). We also scrapped the IMDb data from the web using the ```get_metadata.py``` script. The IMDb data has the character level information, season images, viewer rating etc.\n", + "\n", + "Using the two data source we clean and reformat the data. We also map the correct characters for every dialogue spoken by joining the two datasets. We also format the episode and season naming as per our requirement for the UI." + ] + }, + { + "cell_type": "markdown", + "id": "76bfdd6a-ae72-4675-a1c2-411921fe4a00", + "metadata": {}, + "source": [ + "### Data Profile" + ] + }, + { + "cell_type": "markdown", + "id": "d730c2fe-8eac-4590-bb8c-0f3885306300", + "metadata": {}, + "source": [ + "The raw data from Kaggle is stored in ```game-of-thrones.csv``` and the cleaned data csv is located at ```output_dialogues.csv``` in the data folder" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "2e7dac8e", + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd\n", + "\n", + "df_raw = pd.read_csv(\"../thronetalk-game-of-thrones-summarizer/data/game-of-thrones.csv\")\n", + "df_cleaned = pd.read_csv(\"../thronetalk-game-of-thrones-summarizer/data/ouput_dialogues.csv\")" + ] + }, + { + "cell_type": "markdown", + "id": "bd40b7e9", + "metadata": {}, + "source": [ + "### Raw data" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "f16afe86", + "metadata": {}, + "outputs": [ + { + "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", + "
TextSpeakerEpisodeSeasonShow
0[First scene opens with three Rangers riding t...NaNe1-Winter is Comingseason-01Game-of-Thrones
1What d’you expect? They’re savages. One lot s...WAYMAR ROYCEe1-Winter is Comingseason-01Game-of-Thrones
2I’ve never seen wildlings do a thing like thi...WILLe1-Winter is Comingseason-01Game-of-Thrones
3How close did you get?WAYMAR ROYCEe1-Winter is Comingseason-01Game-of-Thrones
4Close as any man would.WILLe1-Winter is Comingseason-01Game-of-Thrones
\n", + "
" + ], + "text/plain": [ + " Text Speaker \\\n", + "0 [First scene opens with three Rangers riding t... NaN \n", + "1 What d’you expect? They’re savages. One lot s... WAYMAR ROYCE \n", + "2 I’ve never seen wildlings do a thing like thi... WILL \n", + "3 How close did you get? WAYMAR ROYCE \n", + "4 Close as any man would. WILL \n", + "\n", + " Episode Season Show \n", + "0 e1-Winter is Coming season-01 Game-of-Thrones \n", + "1 e1-Winter is Coming season-01 Game-of-Thrones \n", + "2 e1-Winter is Coming season-01 Game-of-Thrones \n", + "3 e1-Winter is Coming season-01 Game-of-Thrones \n", + "4 e1-Winter is Coming season-01 Game-of-Thrones " + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_raw.head()" + ] + }, + { + "cell_type": "markdown", + "id": "38dc19bc", + "metadata": {}, + "source": [ + "### Cleaned data\n", + "\n", + "The cleaned data gets rid of Nans for speaker name. We also observed a few speakers had just the first name and no last name which created repeat characters. After joining the IMDb data we were able to remove this issue and get a unique list of characters with first and last name." + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "f213e11e", + "metadata": {}, + "outputs": [ + { + "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", + "
Unnamed: 0TextSpeakerEpisodeSeasonShowEpisode_nameEpisode_NumberSeason_Numberdialogue_with_speakerCharacter
00[First scene opens with three Rangers riding t...narratore1season-01Game-of-ThronesNaN11NARRATOR:First scene opens with three Rangers ...narrator
11What d’you expect? They’re savages. One lot s...waymare1season-01Game-of-ThronesNaN11WAYMAR ROYCE: What d’you expect? They’re savag...waymar royce
22I’ve never seen wildlings do a thing like thi...wille1season-01Game-of-ThronesNaN11WILL: I’ve never seen wildlings do a thing lik...will
33How close did you get?waymare1season-01Game-of-ThronesNaN11WAYMAR ROYCE: How close did you get?waymar royce
44Close as any man would.wille1season-01Game-of-ThronesNaN11WILL: Close as any man would.will
\n", + "
" + ], + "text/plain": [ + " Unnamed: 0 Text Speaker \\\n", + "0 0 [First scene opens with three Rangers riding t... narrator \n", + "1 1 What d’you expect? They’re savages. One lot s... waymar \n", + "2 2 I’ve never seen wildlings do a thing like thi... will \n", + "3 3 How close did you get? waymar \n", + "4 4 Close as any man would. will \n", + "\n", + " Episode Season Show Episode_name Episode_Number \\\n", + "0 e1 season-01 Game-of-Thrones NaN 1 \n", + "1 e1 season-01 Game-of-Thrones NaN 1 \n", + "2 e1 season-01 Game-of-Thrones NaN 1 \n", + "3 e1 season-01 Game-of-Thrones NaN 1 \n", + "4 e1 season-01 Game-of-Thrones NaN 1 \n", + "\n", + " Season_Number dialogue_with_speaker \\\n", + "0 1 NARRATOR:First scene opens with three Rangers ... \n", + "1 1 WAYMAR ROYCE: What d’you expect? They’re savag... \n", + "2 1 WILL: I’ve never seen wildlings do a thing lik... \n", + "3 1 WAYMAR ROYCE: How close did you get? \n", + "4 1 WILL: Close as any man would. \n", + "\n", + " Character \n", + "0 narrator \n", + "1 waymar royce \n", + "2 will \n", + "3 waymar royce \n", + "4 will " + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_cleaned.head()" + ] + }, + { + "cell_type": "markdown", + "id": "f38b247c-ad89-4386-95d8-6fddb8111aec", + "metadata": {}, + "source": [ + "The final dialogue data, ```ouput_dialogues```, is then stored as a ```.csv``` file in ```'.thronetalk-game-of-thrones-summarizer/data'```" + ] + }, + { + "cell_type": "markdown", + "id": "f0a7651e-8e02-40d3-ba74-8f93ea7a697c", + "metadata": {}, + "source": [ + " ####" + ] + }, + { + "cell_type": "markdown", + "id": "b09bc57f-ec08-4df2-96f0-8bed5b74568e", + "metadata": {}, + "source": [ + "### IMDb Metadata" + ] + }, + { + "cell_type": "markdown", + "id": "48248bd1-a80f-4fc1-985e-c756113eb37c", + "metadata": {}, + "source": [ + "The ```episode_metadata.csv``` dataset contains metadata for each episode of Game of Thrones and ```show_metadata.json``` dataset contains metadata for the show. This data was scraped from IMDb using ```Cinemagoer``` library used in ```scripts/get_metadata.py```. The episodes metadata is generated by ```get_episode_metadata()``` and show metadata is generated using ```get_show_metadata()```." + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "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", + "
titlesynopsisplot outlineseasonepisoderatingruntimesvotesfull-size cover urlplotprevious episode imdb idnext episode imdb idrelease yearcastsdirectorsproducerswriters
0Winter Is Coming['In the Seven Kingdoms of Westeros, a soldier...At the castle Winterfell, Lord Ned Stark begin...118.9['62']53997https://m.media-amazon.com/images/M/MV5BMmVhOD...Eddard Stark is torn between his family and an...313214011668746.02011['Sean Bean', 'Mark Addy', 'Nikolaj Coster-Wal...['Timothy Van Patten']['David Benioff', 'Jonathan Brytus', 'Jo Burn'...['David Benioff', 'D.B. Weiss', 'George R.R. M...
1The Kingsroad['Tyrion doesn\\'t like his dwarf status in the...Although his son Bran is lying in bed unconsci...128.6['56']40785https://m.media-amazon.com/images/M/MV5BYzhhOT...While Bran recovers from his fall, Ned takes o...14800551829962.02011['Sean Bean', 'Mark Addy', 'Nikolaj Coster-Wal...['Timothy Van Patten']['David Benioff', 'Jonathan Brytus', 'Guymon C...['David Benioff', 'D.B. Weiss', 'George R.R. M...
2Lord Snow['Ned reaches King\\'s Landing and is reminded ...After the attempted assassination of young Bra...138.5['58']38620https://m.media-amazon.com/images/M/MV5BZjcwNz...Jon begins his training with the Night's Watch...16687461829963.02011['Sean Bean', 'Mark Addy', 'Nikolaj Coster-Wal...['Brian Kirk']['David Benioff', 'Jonathan Brytus', 'Guymon C...['David Benioff', 'D.B. Weiss', 'George R.R. M...
\n", + "
" + ], + "text/plain": [ + " title synopsis \\\n", + "0 Winter Is Coming ['In the Seven Kingdoms of Westeros, a soldier... \n", + "1 The Kingsroad ['Tyrion doesn\\'t like his dwarf status in the... \n", + "2 Lord Snow ['Ned reaches King\\'s Landing and is reminded ... \n", + "\n", + " plot outline season episode rating \\\n", + "0 At the castle Winterfell, Lord Ned Stark begin... 1 1 8.9 \n", + "1 Although his son Bran is lying in bed unconsci... 1 2 8.6 \n", + "2 After the attempted assassination of young Bra... 1 3 8.5 \n", + "\n", + " runtimes votes full-size cover url \\\n", + "0 ['62'] 53997 https://m.media-amazon.com/images/M/MV5BMmVhOD... \n", + "1 ['56'] 40785 https://m.media-amazon.com/images/M/MV5BYzhhOT... \n", + "2 ['58'] 38620 https://m.media-amazon.com/images/M/MV5BZjcwNz... \n", + "\n", + " plot \\\n", + "0 Eddard Stark is torn between his family and an... \n", + "1 While Bran recovers from his fall, Ned takes o... \n", + "2 Jon begins his training with the Night's Watch... \n", + "\n", + " previous episode imdb id next episode imdb id release year \\\n", + "0 31321401 1668746.0 2011 \n", + "1 1480055 1829962.0 2011 \n", + "2 1668746 1829963.0 2011 \n", + "\n", + " casts directors \\\n", + "0 ['Sean Bean', 'Mark Addy', 'Nikolaj Coster-Wal... ['Timothy Van Patten'] \n", + "1 ['Sean Bean', 'Mark Addy', 'Nikolaj Coster-Wal... ['Timothy Van Patten'] \n", + "2 ['Sean Bean', 'Mark Addy', 'Nikolaj Coster-Wal... ['Brian Kirk'] \n", + "\n", + " producers \\\n", + "0 ['David Benioff', 'Jonathan Brytus', 'Jo Burn'... \n", + "1 ['David Benioff', 'Jonathan Brytus', 'Guymon C... \n", + "2 ['David Benioff', 'Jonathan Brytus', 'Guymon C... \n", + "\n", + " writers \n", + "0 ['David Benioff', 'D.B. Weiss', 'George R.R. M... \n", + "1 ['David Benioff', 'D.B. Weiss', 'George R.R. M... \n", + "2 ['David Benioff', 'D.B. Weiss', 'George R.R. M... " + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "episodes_metadata = pd.read_csv(\"../thronetalk-game-of-thrones-summarizer/data/episodes_metadata.csv\")\n", + "episodes_metadata.head(3)" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'cast': ['Peter Dinklage', 'Lena Headey', 'Emilia Clarke', 'Kit Harington', 'Sophie Turner', 'Maisie Williams', 'Nikolaj Coster-Waldau', 'Iain Glen', 'John Bradley', 'Alfie Allen', 'Conleth Hill', 'Liam Cunningham', 'Gwendoline Christie', 'Aidan Gillen', 'Isaac Hempstead Wright', 'Rory McCann', 'Nathalie Emmanuel', 'Jerome Flynn', 'Daniel Portman', 'Jacob Anderson', 'Ben Crompton', 'Kristofer Hivju', 'Julian Glover', 'Carice van Houten', 'Charles Dance', 'Hannah Murray', 'Natalie Dormer', 'Jack Gleeson', 'Michelle Fairley', 'Ian McElhinney', 'Stephen Dillane', 'Joe Dempsie', 'Kristian Nairn', 'Anton Lesser', 'Mark Stanley', 'Richard Madden', 'Finn Jones', 'Sibel Kekilli', 'Iwan Rheon', 'Michael McElhatton', 'Owen Teale', 'Michiel Huisman', 'Diana Rigg', 'Dean-Charles Chapman', 'Rose Leslie', 'Tom Wlaschiha', 'Hafþór Júlíus Björnsson', \"Brenock O'Connor\", 'Ian Beattie', 'Natalia Tena'], 'end year': 2019, 'full-size cover url': 'https://m.media-amazon.com/images/M/MV5BN2IzYzBiOTQtNGZmMi00NDI5LTgxMzMtN2EzZjA1NjhlOGMxXkEyXkFqcGdeQXVyNjAwNDUxODI@.jpg', 'genres': ['Action', 'Adventure', 'Drama', 'Fantasy'], 'number of seasons': 8, 'plot': ['Nine noble families fight for control over the lands of Westeros, while an ancient enemy returns after being dormant for a millennia.', 'In the mythical continent of Westeros, several powerful families fight for control of the Seven Kingdoms. As conflict erupts in the kingdoms of men, an ancient enemy rises once again to threaten them all. Meanwhile, the last heirs of a recently usurped dynasty plot to take back their homeland from across the Narrow Sea.—Sam Gray', 'Years after a rebellion spurred by a stolen bride to be and the blind ambitions of a mad King, Robert of the house Baratheon (Mark Addy) sits on the much desired Iron Throne. In the mythical land of Westeros, nine noble families fight for every inch of control and every drop of power. The King\\'s Hand, Jon Arryn (Sir John Standing), is dead. And Robert seeks out his only other ally in all of Westeros, his childhood friend Lord Eddard \"Ned\" Stark. The solemn and honorable Warden of the North is tasked to depart his frozen sanctuary and join the King in the capital of King\\'s Landing to help the now overweight and drunk Robert rule. However, a letter in the dead of night informs \"Ned\" that the former Hand was murdered, and that Robert will be next. So noble Ned goes against his better desires in an attempt to save his friend and the kingdoms. But political intrigue, plots, murders, and sexual desires lead to a secret that could tear the Seven Kingdoms apart. And soon Eddard will find out what happens when you play the Game of Thrones.—Gregory Tobin', 'Based on the best-selling book series \"A Song of Ice and Fire\" by George R.R. Martin, this sprawling HBO drama is set in a world where summers span several decades and winters can last a lifetime. From the scheming south and the savage eastern lands, to the frozen north and ancient Wall that protects the realm from the mysterious darkness beyond, the powerful families of the Seven Kingdoms are locked in a battle for the Iron Throne. This is a story of duplicity and treachery, nobility and honor, conquest and triumph. In the Game of Thrones, you either win or you die.—ahmetkozan', 'In the mythical continent of Westeros, nine families of higher nobility (Targaryen, Lannisters, Starks, Tyrell, Martell, Greyjoys, Baratheons and Boltons) scramble bitterly to gain power over the seven kingdoms and the Iron throne. As Westeros becomes rife with political unrests, conflicts, treachery, murder and debauchery, an ancient enemy (Army of the dead) awakens and strike the sense of doom to the living folks of Westeros.—mwitamaibuni'], 'plot outline': 'In the mythical continent of Westeros, several powerful families fight for control of the Seven Kingdoms. As conflict erupts in the kingdoms of men, an ancient enemy rises once again to threaten them all. Meanwhile, the last heirs of a recently usurped dynasty plot to take back their homeland from across the Narrow Sea.', 'rating': 9.2, 'release year': 2011, 'runtimes': ['4189'], 'synopsis': ['The imaginary continent of Westeros was once inhabited by a magical people, the Children of the Forest. For centuries, other people came across the Narrow Sea from the eastern continent of Essos: up North, the First Men; in the Center, the Andals; down South, the Dornish. With time, the Chirldren of the Forest were relegated to the world of legends, and the different ethnicities divided the continent in seven major kingdoms.\\nNow, in thus South of Essos, there was a ancient and powerful civilization called Valyria, that ruled through magic and dragons. Valyrians also came to Westeros and established three clans: the Velaryon, the Celtigar, and the powerful dragon-riders, the Targaryens.\\nOne such Targaryen, Aegon the Conqueror, united the Seven Kingdoms of Westeros under his rule, and the Targaryens controlled Westeros for centuries, even after their homeland of Valyria was destroyed in a mysterious holocaust.\\nThe Targaryen rule was an unstable balance between their pagan valyrian rituals, based on incest to keep their blood-line pure since it was their valyrian blood that allowed them control of the dragons; and the several religions and uses of Westeros, among them the andal religion of The Seven Gods. Many wars were fought until King Jaeherys established peace and balance in Westeros.\\nUnfortunately, a war among the Targaryens family, called The Dance of The Dragons, destroyed most of the Targaryens and their dragons. The Targaryen power dwindled for generations, until their last king Aerys II, the \"Mad King\", haunted by delusions and hallucinations, abused his power and insulted many of the major families of the Seven Kingdoms.\\nWar ensued. After kidnapping a young lady from the Stark clan (rulers of the North and descendants of the First Men) and killing her father and brother who claimed for justice, the younger brother Ned Stark allied with her betrothed Robert Baratheon, lord of Storm\\'s End and an andal, and the Targaryens were deposed of the throne and killed, in battle or massacre, but for two young babies promptly evacuated to Essos.\\nSeveral years later, this show begins.\\nA three-men team surveils the frozen north to find there is an ancient menace returning, but the remaining survivor, a simple fool, is thought to be crazy and is beheaded for desertion by a much older Ned Stark.\\nAt the same time, his village is visited by the king Robert Baratheon, now an old and fat man, married to a lady from the Lannister clan (and former allies of the Targaryens - before they betrayed them when they realized Baratheon was winning the war).\\nThe right-hand man of the King, aptly named \"Hand of the King\" died in mysterious circumstances, and Robert names Ned Stark his successor to find what happened.\\nDuring his stay in the capital, King\\'s Landing, Ned Stark finds that the former Hand of the King discovered a major conspiracy by the queen Cersei Lannister, and that her sons and heirs to the throne were bastards. But the King dies of a \"hunting accident\" and the queen takes the throne to her son. Trying to denounce the coup, Ned Stark is arrested and beheaded by his own sword.\\nHis men are all killed, and only her two daughters survive - the naive Sansa, betrothed to the new king, and Arya, a tom-boy who escapes.\\nHis elder son, Robb Stark, is named King in the North, and rides down on King\\'s Landing to avenge his father. Other contestants claim the crown too, starting a war that ravages the Seven Kingdoms and takes up most of the first three seasons.\\nRobb Stark is killed by treason, and the Lannisters consider the war won. But then the young king Joffrey is poisoned, and all blame falls on the uncle, a very smart dwarf that the queen hates because she blames him for killing their mother during labor. The dwarf, Tyrion Lannister, escapes but his adventures make up part of most of the remaining seasons\\nQueen Cersei replaces Joffrey by another son, but then King\\'s Landing is taken by a powerful religious movement, that denounces her as incestuous - and shames her in front of everybody in King\\'s Landing. Cersei ends killing everybody in revenge, including the betrothed new queen. And his last son commits suicide out of grief. Cersei is now the sole ruler of Westeros. Or should be...\\n... because, since the first episode, the two Targaryenm babies, now young adults, are conspiring in Essos to take back their crown. Viserys, a mad ambitious young man, ends up being killed but his sister, Daennerys, marries a powerful warlord, and receives three dragon eggs as wedding gift. Thought to be old barren eggs, turned into stone, Daennerys manages to hatch them, and her adventures begin at the end of the first season. Expelled from the tribe after her husband\\'s death, she crosses the desert, faces all sort of dangers and enemies, until she manages to reach a slave city, where she sells her dragons to buy an army of thousands of slaves - then turns her dragons on the slave-owners. Thus begins her story as \"Breaker of Chains\".\\nAfter invading and destroying all slaver cities, and freeing millions of people, she manages to reconquer her old tribe, and crosses the Narrow Sea to invade Westeros.\\nBut, up North... Ned Starks bastard, Jon Snow, joins the Night\\'s Watch, a militia of \"forced volunteers\" that watches over a big, magical wall of ice that separates the Lands of Always Winter, up North, and the remaining of Westeros. He discovers the ancient peril the simple fool alerted about in the first episode, is all too real. He rises to commander of the Night\\'s Watch and unites his men to the lost tribes of Wildlings, free men that roam the northern lands above the Wall, free of the laws of the Seven Kingdoms.\\nHe manages to save them all from an attack of wights, zombie-like dead people, reanimated by the magic of thus mysterious White Walkers, people that seem made of ice - and are led by the Night King.\\nBut the Night\\'s Watch does not like his decisions, so they kill him.\\nAnd here the books end their story.\\nBut the show goes further on.\\nUsing magic, a mysterious sorcerer called Melisandre, that worships the Lord of Light and fights the Night King, reanimates Jon Snow. Thus begins the story of Jon Snow, future King in the North.\\nIn the remaining episodes, Jon Snow manages to take back the castle of Winterfell, that belonged to the Starks, and reunites with a much less naive Sansa Stark, who became a intelligent ruler, and a cruel Arya Stark, who became an assassin. They also reunite with the much younger Bran Stark, who had acquired magical powers that allowed to see the past.\\nTogether, they manage to ally with Daennerys Targaryen in their fight against the Lannisters, but also against the army of the dead, led by the Night King. His army attacks Winterfell to kill Bran Stark, for he\\'s the only one with powers to stop the Night King. The battle is overwhelming - and the Night King has one of Daennerys\\'s dragons, that he killed and reanimated as an ice dragon! In the last minute, when the Night King is about to kill a defenseless Bran Stark, Arya show her prowess as assassin and stabs the Night King with a very famous Valyrian blade (the dagger of Aegon the Conqueror, the first Targaryen king; this dagger is important in the story of the show House of the Dragon, and was also used in an attempt on the life of Bran Stark in the beginning of the show).\\nAfter defeating the Night King, the conjoint armies of the Jon Snow\\'s Northernmen and Daennerys\\'s savage riders attack King\\'s Landing and defeat the Lannisters. But Daennerys shows she\\'s really the \"Mad King\"\\'s daughter by destroying King\\'s Landing even after the surrender of the city, and she vows on the total submission of the entire Seven Kingdoms like her ancestors did - thus endangering the freedom of the Northernmen.\\nJon Snow, who grew up to be her lover, makes a final sacrifice by killing her to ensure lasting peace in Westeros.And this is but an iota of the many stories, surprises, plots and mysteries of the show. And the books are even more surprising!'], 'title': 'Game of Thrones', 'votes': 2256103, 'writers': ['David Benioff', 'David Benioff', 'David Benioff']}\n" + ] + } + ], + "source": [ + "import json\n", + "\n", + "with open('../thronetalk-game-of-thrones-summarizer/data/show_metadata.json') as f:\n", + " d = json.load(f)\n", + " print(d)" + ] + }, + { + "cell_type": "markdown", + "id": "a48c86b4-6cde-4f1c-a3b4-b42153e515cb", + "metadata": {}, + "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.11.5" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/scripts/get_metadata.py b/scripts/get_metadata.py index a1fc7db..0b3a85e 100644 --- a/scripts/get_metadata.py +++ b/scripts/get_metadata.py @@ -158,6 +158,6 @@ def write_episode_metadata(output_file, episodes_data): if __name__ == "__main__": data = get_show_metadata(IMDB_GOT_ID) - write_show_metadata('../data/show_metadata.json', data) + write_show_metadata('./thronetalk-game-of-thrones-summarizer/data/show_metadata.json', data) episodes_metadata = get_episode_metadata() - write_episode_metadata('../data/episodes_metadata.csv', episodes_metadata) + write_episode_metadata('./thronetalk-game-of-thrones-summarizer/data/episodes_metadata.csv', episodes_metadata) diff --git a/thronetalk-game-of-thrones-summarizer/static/thronetalk_title.png b/thronetalk-game-of-thrones-summarizer/static/thronetalk_title.png new file mode 100644 index 0000000..45b9c1b Binary files /dev/null and b/thronetalk-game-of-thrones-summarizer/static/thronetalk_title.png differ diff --git a/thronetalk-game-of-thrones-summarizer/tests/mock_functions.py b/thronetalk-game-of-thrones-summarizer/tests/mock_functions.py index 5e1e61c..bbf3aad 100644 --- a/thronetalk-game-of-thrones-summarizer/tests/mock_functions.py +++ b/thronetalk-game-of-thrones-summarizer/tests/mock_functions.py @@ -28,6 +28,8 @@ def mocked_read_csv_ouput_dialogues(*args): dataframe = pd.DataFrame(mock_rows, columns=columns) return dataframe +# *args is required to catch arguments passed while using with +# unittest's @patch, disabling the pylint warning. # pylint: disable=unused-argument def mock_model_azure_api_call(*args): '''Mocks the response of azure_api_call from model.py's Model class.''' diff --git a/thronetalk-game-of-thrones-summarizer/tests/test_data_analysis.py b/thronetalk-game-of-thrones-summarizer/tests/test_data_analysis.py index a9491d5..704775f 100644 --- a/thronetalk-game-of-thrones-summarizer/tests/test_data_analysis.py +++ b/thronetalk-game-of-thrones-summarizer/tests/test_data_analysis.py @@ -120,3 +120,6 @@ def test_get_list_of_chars(self): data_analysis = DataAnalysis(self.dialogue_data) characters = data_analysis.get_list_of_characters(1, 1, 1, 2) self.assertCountEqual(characters, ['arya', 'jon snow', 'daenerys', 'narrator', 'tyrion']) + +if __name__ == "__main__": + unittest.main() diff --git a/thronetalk-game-of-thrones-summarizer/tests/test_model.py b/thronetalk-game-of-thrones-summarizer/tests/test_model.py index 6785100..b96163f 100644 --- a/thronetalk-game-of-thrones-summarizer/tests/test_model.py +++ b/thronetalk-game-of-thrones-summarizer/tests/test_model.py @@ -18,6 +18,7 @@ def test_edge_init(self): '''Edge tests for Model''' with self.assertRaises(TypeError): Model() # pylint: disable=no-value-for-parameter + # disabling pylint to allow checking for empty class initialization with self.assertRaises(ValueError): Model("","","","") with self.assertRaises(ValueError): diff --git a/thronetalk-game-of-thrones-summarizer/tests/test_visualization_generator.py b/thronetalk-game-of-thrones-summarizer/tests/test_visualization_generator.py index 03b39ba..982b3a5 100644 --- a/thronetalk-game-of-thrones-summarizer/tests/test_visualization_generator.py +++ b/thronetalk-game-of-thrones-summarizer/tests/test_visualization_generator.py @@ -23,6 +23,7 @@ def test_edge_init(self): '''Edge tests for VisualizationGenerator''' with self.assertRaises(TypeError): VisualizationGenerator() # pylint: disable=no-value-for-parameter + # disabling pylint to allow checking for empty class initialization with self.assertRaises(ValueError): VisualizationGenerator("","","","") with self.assertRaises(ValueError): @@ -39,6 +40,7 @@ def test_edge_sentiment_analysis_visualization(self): v_g = VisualizationGenerator(1,1,1,2) with self.assertRaises(TypeError): v_g.sentiment_analysis_visualization() # pylint: disable=no-value-for-parameter + # disabling pylint to allow checking for empty class initialization with self.assertRaises(TypeError): v_g.sentiment_analysis_visualization("") with self.assertRaises(ValueError): @@ -53,6 +55,7 @@ def test_edge_wordcloud(self): v_g = VisualizationGenerator(1,1,1,2) with self.assertRaises(TypeError): v_g.multi_word_cloud() # pylint: disable=no-value-for-parameter + # disabling pylint to allow checking for empty class initialization with self.assertRaises(TypeError): v_g.multi_word_cloud("") with self.assertRaises(ValueError): diff --git a/thronetalk-game-of-thrones-summarizer/utils/model.py b/thronetalk-game-of-thrones-summarizer/utils/model.py index 08ae367..2831ea8 100644 --- a/thronetalk-game-of-thrones-summarizer/utils/model.py +++ b/thronetalk-game-of-thrones-summarizer/utils/model.py @@ -25,6 +25,7 @@ def __init__(self, season_from: int, episode_from: int, episode_to: The ending episode number (inclusive) within the ending season. """ # Python raises `TypeError` automatically if we don't provide the kwargs + # (we'll need separate validation codes to check for both Model and VisualizationGenerator) # pylint: disable=duplicate-code params = [season_from, episode_from, season_to, episode_to] if any(not isinstance(param, int) for param in params):