Skip to content

Commit

Permalink
Merge pull request #49 from DSProjects2024/raagul/prod-fix
Browse files Browse the repository at this point in the history
Updated file reading logic for prod streamlit
  • Loading branch information
abhinavdv authored Mar 13, 2024
2 parents 8da4bae + 27c31be commit 0d61df9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
10 changes: 3 additions & 7 deletions thronetalk-game-of-thrones-summarizer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
import time
import streamlit as st
import pandas as pd
#import numpy as np
import matplotlib.pyplot as plt
#from wordcloud import WordCloud
from utils.model import Model
from utils.visualization_generator import VisualizationGenerator
from utils.visualization_generator import VisualizationGenerator, read_dataframe
from utils.data_analysis import DataAnalysis
import altair as alt

Expand Down Expand Up @@ -78,7 +76,7 @@ def remove_zeros(lst):
season_to = int(season_to)
to_ep_no = int(to_ep_no)
if submitted:
cleaned_data = pd.read_csv(f'{current_directory}/data/ouput_dialogues.csv')
cleaned_data = read_dataframe('ouput_dialogues.csv')
data_analysis = DataAnalysis(cleaned_data)
top_3_characters = data_analysis.get_top_n_characters(
from_season=int(season_from),
Expand All @@ -104,8 +102,6 @@ def remove_zeros(lst):
int(to_ep_no)
)
line_chart = vg.sentiment_analysis_visualization(characters)
line_chart = vg.sentiment_analysis_visualization(characters)
print(characters)
chart = alt.Chart(line_chart).transform_fold(
characters, as_=["character name", "value"]
).mark_line(
Expand Down Expand Up @@ -144,7 +140,7 @@ def remove_zeros(lst):
st.subheader(characters[i].capitalize())
st.pyplot(plots[i])
st.write("\n")
episodes_metadata_for_img_df = pd.read_csv('data/episodes_metadata.csv')
episodes_metadata_for_img_df = read_dataframe('episodes_metadata.csv')
st.subheader(out_text_temp)
#Summarizer
def spinner_loading_summary():
Expand Down
2 changes: 1 addition & 1 deletion thronetalk-game-of-thrones-summarizer/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
Use these functions within your Streamlit app to enhance its capabilities.
"""
from .visualization_generator import VisualizationGenerator
from .visualization_generator import VisualizationGenerator, read_dataframe
from .model import Model
from .data_analysis import DataAnalysis
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,24 @@
from nltk.stem import WordNetLemmatizer
from wordcloud import WordCloud, STOPWORDS
from sklearn.feature_extraction.text import TfidfVectorizer

nltk.download('punkt')
nltk.download('wordnet')
nltk.download('vader_lexicon')
nltk.download('stopwords')
nltk.download('omw-1.4')

data = pd.read_csv("data/ouput_dialogues.csv")
def read_dataframe(file_name):
'''Function to read dataframe for different environments. Used for tests
and app.py'''
file_data = None
try:
file_data = pd.read_csv(f'data/{file_name}')
except FileNotFoundError:
file_data = pd.read_csv(f'./thronetalk-game-of-thrones-summarizer/data/{file_name}')
return file_data

data = read_dataframe('ouput_dialogues.csv')

class VisualizationGenerator:
"""
Expand Down

0 comments on commit 0d61df9

Please sign in to comment.