Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,15 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import networkx as nx
|
| 3 |
import matplotlib.pyplot as plt
|
|
|
|
| 4 |
from nltk import sent_tokenize
|
| 5 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
| 6 |
from sklearn.cluster import KMeans
|
| 7 |
import numpy as np
|
| 8 |
|
|
|
|
|
|
|
|
|
|
| 9 |
# Helper function to split text into topics using KMeans clustering
|
| 10 |
def split_text_into_topics(text, n_topics):
|
| 11 |
sentences = sent_tokenize(text)
|
|
@@ -89,4 +93,3 @@ if uploaded_file is not None:
|
|
| 89 |
nx.draw(graph, pos, with_labels=True, node_size=3000, node_color="lightblue", font_size=10, font_weight="bold", labels={node: node for node in graph.nodes()})
|
| 90 |
plt.title("Tree Structure of Text Topics")
|
| 91 |
st.pyplot(plt)
|
| 92 |
-
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import networkx as nx
|
| 3 |
import matplotlib.pyplot as plt
|
| 4 |
+
import nltk
|
| 5 |
from nltk import sent_tokenize
|
| 6 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
| 7 |
from sklearn.cluster import KMeans
|
| 8 |
import numpy as np
|
| 9 |
|
| 10 |
+
# Download the punkt tokenizer
|
| 11 |
+
nltk.download('punkt')
|
| 12 |
+
|
| 13 |
# Helper function to split text into topics using KMeans clustering
|
| 14 |
def split_text_into_topics(text, n_topics):
|
| 15 |
sentences = sent_tokenize(text)
|
|
|
|
| 93 |
nx.draw(graph, pos, with_labels=True, node_size=3000, node_color="lightblue", font_size=10, font_weight="bold", labels={node: node for node in graph.nodes()})
|
| 94 |
plt.title("Tree Structure of Text Topics")
|
| 95 |
st.pyplot(plt)
|
|
|