Skip to content

Commit

Permalink
Merge pull request #48 from DSProjects2024/abhinavdv/add-descriptions…
Browse files Browse the repository at this point in the history
…-for-app.py

Added descriptions to each chart
  • Loading branch information
swarali-desai authored Mar 13, 2024
2 parents c937e99 + aad9934 commit 7470120
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
21 changes: 20 additions & 1 deletion thronetalk-game-of-thrones-summarizer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def remove_zeros(lst):
filtered_to_episode, key = 2)
to_ep_no = selected_episode_to.split()[4]
submitted = st.sidebar.button("Generate Summary")
H1 = "Sentiment Analysis & Word Clouds from"
H1 = "Sentiment Scores Across"
out_text_temp = f"**Episode Summary from {selected_episode_from} to {selected_episode_to}**"
out_text_temp2 = f"**{H1} {selected_episode_from} to {selected_episode_to}**"
season_from = int(season_from)
Expand All @@ -90,13 +90,22 @@ def remove_zeros(lst):
#st.write(characters_tuple)
characters = list(characters_tuple)
st.subheader(out_text_temp2)
st.markdown('''This line chart visualizes the ***sentiment scores*** across seasons and episodes
for the top 3 most active characters within the range selected by the user,
based ***on-screen time***. Sentiment scores reflect the emotional tone of dialogue
and actions, with positive scores indicating positive sentiment and negative scores
indicating negative sentiment. This visualization allows users to track the
emotional journey of key characters throughout the series, identifying trends,
patterns, and significant moments in their development.''')
vg = VisualizationGenerator(
int(season_from),
int(from_ep_no),
int(season_to),
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 All @@ -111,6 +120,16 @@ def remove_zeros(lst):

)
st.altair_chart(chart,use_container_width=True)
H2 = "Word Cloud of top 3 characters from "
out_text_2 = f"**{H2} {selected_episode_from} to {selected_episode_to}**"
st.subheader(out_text_2)
st.markdown('''These word clouds display the most frequently used words
associated with the top 3 characters selected from the sentiment
analysis above. Each word cloud visually represents the prominence
of words in the dialogue or actions of these characters throughout
the selected seasons and episodes. Larger words indicate higher
frequency of use, offering users a glimpse into the key themes,
topics, and attributes associated with each character.''')
columns = st.columns(len(characters))
wordcloud = vg.multi_word_cloud(characters)
plots = []
Expand Down
4 changes: 2 additions & 2 deletions thronetalk-game-of-thrones-summarizer/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ def test_headers(self, _):
self.mock_input()
from_ep_full2 = self.app_test.sidebar.selectbox[1].value
to_ep_full2 = self.app_test.sidebar.selectbox[3].value
sub_header1= f"**Sentiment Analysis & Word Clouds from {from_ep_full2} to {to_ep_full2}**"
sub_header1= f"**Sentiment Scores Across {from_ep_full2} to {to_ep_full2}**"
sub_header2= f"**Episode Summary from {from_ep_full2} to {to_ep_full2}**"
episode_summary_subheader = self.app_test.subheader[4].value
episode_summary_subheader = self.app_test.subheader[5].value
sentiment_analysis_subheader = self.app_test.subheader[0].value
self.assertEqual(sentiment_analysis_subheader,sub_header1)
self.assertEqual(episode_summary_subheader,sub_header2)
Expand Down

0 comments on commit 7470120

Please sign in to comment.