awacke1 commited on
Commit
b2048f3
·
1 Parent(s): 89b83cd

Create backup.app.py

Browse files
Files changed (1) hide show
  1. backup.app.py +43 -0
backup.app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from collections import Counter
3
+ import plotly.express as px
4
+ import numpy as np
5
+
6
+ def get_word_score(word):
7
+ # This function returns a score based on the length of the word
8
+ # Modify this function as per your requirements
9
+ score = len(word)**2
10
+ return score
11
+
12
+ def get_word_frequency(text):
13
+ # This function returns the word frequency of the given text
14
+ words = text.split()
15
+ word_frequency = Counter(words)
16
+ return word_frequency
17
+
18
+ # Load the markdown file
19
+ with open('Setup.md', 'r') as file:
20
+ text = file.read()
21
+
22
+
23
+ # Display the parsed markdown
24
+ st.markdown(text, unsafe_allow_html=True)
25
+
26
+ # Get the word frequency of the markdown text
27
+ word_frequency = get_word_frequency(text)
28
+
29
+ # Get the top words and their frequency
30
+ top_words = word_frequency.most_common(10)
31
+ top_words_dict = dict(top_words)
32
+
33
+ # Create a Plotly bar chart to display the top words and their frequency
34
+ fig = px.bar(x=list(top_words_dict.keys()), y=list(top_words_dict.values()), labels={'x':'Word', 'y':'Frequency'})
35
+ st.plotly_chart(fig)
36
+
37
+ # Calculate the scores for each word based on their length
38
+ word_scores = {word:get_word_score(word) for word in word_frequency}
39
+ top_word_scores = dict(sorted(word_scores.items(), key=lambda item: item[1], reverse=True)[:10])
40
+
41
+ # Create a Plotly bar chart to display the top words and their scores
42
+ fig = px.bar(x=list(top_word_scores.keys()), y=list(top_word_scores.values()), labels={'x':'Word', 'y':'Score'})
43
+ st.plotly_chart(fig)