awacke1 commited on
Commit
92eb8dc
โ€ข
1 Parent(s): d42652d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -12
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import streamlit as st
2
  import re
3
  import nltk
@@ -6,6 +7,7 @@ from nltk.corpus import stopwords
6
  from nltk import FreqDist
7
  from graphviz import Digraph
8
 
 
9
  nltk.download('punkt')
10
  nltk.download('stopwords')
11
 
@@ -64,15 +66,17 @@ def display_context_table(context_words):
64
  table += f"| {before if before else ''} | {high} | {after if after else ''} |\n"
65
  st.markdown(table)
66
 
 
67
  def load_example_files():
68
  example_files = [f for f in os.listdir() if f.endswith('.txt')]
69
- selected_file = st.selectbox("Select an example file:", example_files)
70
- if st.button(f"Load {selected_file}"):
71
  with open(selected_file, 'r', encoding="utf-8") as file:
72
  return file.read()
73
  return None
74
 
75
- uploaded_file = st.file_uploader("Choose a .txt file", type=['txt'])
 
76
 
77
  example_text = load_example_files()
78
 
@@ -85,17 +89,18 @@ else:
85
 
86
  if file_text:
87
  text_without_timestamps = remove_timestamps(file_text)
88
-
89
  top_words = extract_high_information_words(text_without_timestamps, 10)
90
- st.markdown("**Top 10 High Information Words:**")
91
- st.write(top_words)
92
 
93
- st.markdown("**Relationship Graph:**")
94
- display_relationship_graph(top_words)
 
 
 
95
 
96
  context_words = extract_context_words(text_without_timestamps, top_words)
97
- st.markdown("**Context Graph:**")
98
- display_context_graph(context_words)
99
 
100
- st.markdown("**Context Table:**")
101
- display_context_table(context_words)
 
 
 
 
1
+ # Import necessary libraries
2
  import streamlit as st
3
  import re
4
  import nltk
 
7
  from nltk import FreqDist
8
  from graphviz import Digraph
9
 
10
+ # Download NLTK resources
11
  nltk.download('punkt')
12
  nltk.download('stopwords')
13
 
 
66
  table += f"| {before if before else ''} | {high} | {after if after else ''} |\n"
67
  st.markdown(table)
68
 
69
+ # Load example files
70
  def load_example_files():
71
  example_files = [f for f in os.listdir() if f.endswith('.txt')]
72
+ selected_file = st.selectbox("๐Ÿ“„ Select an example file:", example_files)
73
+ if st.button(f"๐Ÿ“‚ Load {selected_file}"):
74
  with open(selected_file, 'r', encoding="utf-8") as file:
75
  return file.read()
76
  return None
77
 
78
+ # Main code for UI
79
+ uploaded_file = st.file_uploader("๐Ÿ“ Choose a .txt file", type=['txt'])
80
 
81
  example_text = load_example_files()
82
 
 
89
 
90
  if file_text:
91
  text_without_timestamps = remove_timestamps(file_text)
 
92
  top_words = extract_high_information_words(text_without_timestamps, 10)
 
 
93
 
94
+ with st.expander("๐Ÿ“Š Top 10 High Information Words"):
95
+ st.write(top_words)
96
+
97
+ with st.expander("๐Ÿ“ˆ Relationship Graph"):
98
+ display_relationship_graph(top_words)
99
 
100
  context_words = extract_context_words(text_without_timestamps, top_words)
 
 
101
 
102
+ with st.expander("๐Ÿ”— Context Graph"):
103
+ display_context_graph(context_words)
104
+
105
+ with st.expander("๐Ÿ“‘ Context Table"):
106
+ display_context_table(context_words)