+
+
Here are some important facts:
+
+
+ """,unsafe_allow_html=True)
+
+
+ c = alt.Chart(words_df.head(20)).mark_bar().encode(
+ color='Word Count',
+ y=alt.Y('Word',sort='-x'),
+ x='Word Count',
+ tooltip = ['Word','Word Count']
+ ).properties(
+ title = 'Word Frequency Chart'
+ ).configure_mark(
+ opacity=1,
+ # color='red'
+ )
+ if report==0:
+ st.write("Below is the word frequency chart of ",selected_user)
+ st.altair_chart(c, use_container_width=True)
+ c.save('word_chart.png')
+ # return most_common_df
+
+def emoji_table(df,selected_user,report):
+ if selected_user != 'Overall':
+ df = df[df['Author'] == selected_user]
+ emojis = []
+ for message in df['Message']:
+ for c in message:
+ if c in emoji.UNICODE_EMOJI['en']:
+ emojis.append(c)
+ # if any(char in emoji.UNICODE_EMOJI['en'] for char in message):
+ # print(message)
+ # emojis.append(message)
+ # emoji_df = pd.DataFrame(Counter(emojis).most_common(20))
+ # print(emojis)
+ unique_emojis = set(emojis)
+ count_emojis = dict.fromkeys(unique_emojis, 0)
+
+ for e in emojis:
+ count_emojis[e] = count_emojis[e] + 1
+
+ # for e in unique_emojis:
+ # print(e,count_emojis[e])
+ count_emojis = {key: value for key, value in sorted(count_emojis.items(), key=lambda item: item[1],reverse=True)}
+ count_emojis = dict(itertools.islice(count_emojis.items(), 10))
+ emoji_df = pd.DataFrame.from_dict(count_emojis,orient ='index',columns=['Emoji Count'])
+ # st.bar_chart(emoji_df)
+ # st.write(emoji_df)
+ emoji_df['Emoji'] = emoji_df.index
+
+ c = alt.Chart(emoji_df.head(20)).mark_bar().encode(
+ color='Emoji Count',
+ # y='Emoji',
+ y=alt.Y('Emoji', sort='-x'),
+ x='Emoji Count',
+ tooltip = ['Emoji','Emoji Count']
+ ).properties(
+ title = 'Emoji Frequency Chart'
+ ).configure_mark(
+ opacity=1,
+ # color='red'
+ )
+ if report==0:
+ st.write("Below is the emoji frequency chart of ",selected_user)
+ st.altair_chart(c, use_container_width=True)
+
+ c.save('emoji_chart.png')
+ # Horizontal stacked bar chart
+ # data = pd.melt(emoji_df.reset_index(), id_vars=["index"])
+ # chart = (
+ # alt.Chart(data)
+ # .mark_bar()
+ # .encode(
+ # x=alt.X("value", type="quantitative", title=""),
+ # y=alt.Y("index", type="nominal", title=""),
+ # color=alt.Color("variable", type="nominal", title=""),
+ # order=alt.Order("variable", sort="descending"),
+ # )
+ # )
+ # st.altair_chart(chart, use_container_width=True)
+
+
+ #emoji analysis
+ # emoji_df = helper.emoji_helper(selected_user, df)
+ # st.title("Emojis Analysis")
+ # cnt = 0
+ # for key,value in count_emojis.items():
+ # if cnt>=5:
+ # break
+ # cnt = cnt + 1
+ # st.markdown(f"""
+ #