|
import streamlit as st |
|
from collections import Counter |
|
import plotly.express as px |
|
import numpy as np |
|
|
|
def get_word_score(word): |
|
|
|
|
|
score = len(word)**2 |
|
return score |
|
|
|
def get_word_frequency(text): |
|
|
|
words = text.split() |
|
word_frequency = Counter(words) |
|
return word_frequency |
|
|
|
|
|
with open('Setup.md', 'r') as file: |
|
text = file.read() |
|
|
|
|
|
|
|
st.markdown(text, unsafe_allow_html=True) |
|
|
|
|
|
word_frequency = get_word_frequency(text) |
|
|
|
|
|
top_words = word_frequency.most_common(10) |
|
top_words_dict = dict(top_words) |
|
|
|
|
|
fig = px.bar(x=list(top_words_dict.keys()), y=list(top_words_dict.values()), labels={'x':'Word', 'y':'Frequency'}) |
|
st.plotly_chart(fig) |
|
|
|
|
|
word_scores = {word:get_word_score(word) for word in word_frequency} |
|
top_word_scores = dict(sorted(word_scores.items(), key=lambda item: item[1], reverse=True)[:10]) |
|
|
|
|
|
fig = px.bar(x=list(top_word_scores.keys()), y=list(top_word_scores.values()), labels={'x':'Word', 'y':'Score'}) |
|
st.plotly_chart(fig) |
|
|