Update app.py
Browse files
app.py
CHANGED
@@ -82,4 +82,26 @@ if st.button('Analyze'):
|
|
82 |
nx.draw_networkx_edges(G, pos, edge_color='gray', alpha=0.5)
|
83 |
nx.draw_networkx_labels(G, pos, font_size=8)
|
84 |
ax.axis('off')
|
85 |
-
st.pyplot(fig)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
nx.draw_networkx_edges(G, pos, edge_color='gray', alpha=0.5)
|
83 |
nx.draw_networkx_labels(G, pos, font_size=8)
|
84 |
ax.axis('off')
|
85 |
+
st.pyplot(fig)
|
86 |
+
|
87 |
+
# Generate a short summary using high-use words and terms
|
88 |
+
summary = ' '.join(word_counts.index[:5]) # Use top 5 words/terms for summary
|
89 |
+
st.markdown(f"### Short Summary\n```python\n{summary}\n```")
|
90 |
+
|
91 |
+
# Generate glossary-style sentences for each high-use word/term
|
92 |
+
glossary = {}
|
93 |
+
for word in word_counts.index[:20]:
|
94 |
+
# Find the word in the text and extract surrounding words
|
95 |
+
start_index = text_input.find(word)
|
96 |
+
if start_index != -1:
|
97 |
+
end_index = start_index + len(word)
|
98 |
+
start_context = max(0, start_index - 20)
|
99 |
+
end_context = min(len(text_input), end_index + 20)
|
100 |
+
context = text_input[start_context:start_index] + ' ' + word + ' ' + text_input[end_index:end_context]
|
101 |
+
glossary[word] = context.replace('\n', ' ').strip()
|
102 |
+
|
103 |
+
# Display the glossary-style sentences in markdown format
|
104 |
+
st.markdown("### Glossary")
|
105 |
+
for word, sentence in glossary.items():
|
106 |
+
st.markdown(f"```python\n{word}: {sentence}\n```")
|
107 |
+
|