Team Ai
Apppublic

AzureModels4AI/Azure.Streamlit.Github.Actions.Azure.Container.Registry.Docker.AKS

sourceHugging Facemitupdated 2y agoView on Hugging Face
0likes
app.py44 linesDownload Raw Back to root
1import streamlit as st2from collections import Counter3import plotly.express as px4import numpy as np5 6def get_word_score(word):7    # This function returns a score based on the length of the word8    # Modify this function as per your requirements9    score = len(word)**210    return score11 12def get_word_frequency(text):13    # This function returns the word frequency of the given text14    words = text.split()15    word_frequency = Counter(words)16    return word_frequency17 18# Load the markdown file19with open('Setup.md', 'r') as file:20    text = file.read()21 22 23# Display the parsed markdown24st.markdown(text, unsafe_allow_html=True)25 26# Get the word frequency of the markdown text27word_frequency = get_word_frequency(text)28 29# Get the top words and their frequency30top_words = word_frequency.most_common(10)31top_words_dict = dict(top_words)32 33# Create a Plotly bar chart to display the top words and their frequency34fig = px.bar(x=list(top_words_dict.keys()), y=list(top_words_dict.values()), labels={'x':'Word', 'y':'Frequency'})35st.plotly_chart(fig)36 37# Calculate the scores for each word based on their length38word_scores = {word:get_word_score(word) for word in word_frequency}39top_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 scores42fig = px.bar(x=list(top_word_scores.keys()), y=list(top_word_scores.values()), labels={'x':'Word', 'y':'Score'})43st.plotly_chart(fig)44