Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,7 @@ from tools.final_answer import FinalAnswerTool
|
|
| 7 |
import nltk
|
| 8 |
import networkx as nx
|
| 9 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
|
|
|
| 10 |
from nltk.tokenize import sent_tokenize
|
| 11 |
|
| 12 |
# Ensure necessary NLTK resources are downloaded
|
|
@@ -57,7 +58,7 @@ def extract_sent(doc: str, top_n: int = 3) -> list:
|
|
| 57 |
sentence_vectors = vectorizer.fit_transform(sentences)
|
| 58 |
|
| 59 |
# Step 3: Compute similarity matrix (cosine similarity)
|
| 60 |
-
similarity_matrix = (sentence_vectors
|
| 61 |
|
| 62 |
# Step 4: Create a graph where nodes are sentences, and edges are similarities
|
| 63 |
sentence_graph = nx.from_numpy_array(similarity_matrix)
|
|
|
|
| 7 |
import nltk
|
| 8 |
import networkx as nx
|
| 9 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
| 10 |
+
from sklearn.metrics.pairwise import cosine_similarity
|
| 11 |
from nltk.tokenize import sent_tokenize
|
| 12 |
|
| 13 |
# Ensure necessary NLTK resources are downloaded
|
|
|
|
| 58 |
sentence_vectors = vectorizer.fit_transform(sentences)
|
| 59 |
|
| 60 |
# Step 3: Compute similarity matrix (cosine similarity)
|
| 61 |
+
similarity_matrix = cosine_similarity(sentence_vectors)
|
| 62 |
|
| 63 |
# Step 4: Create a graph where nodes are sentences, and edges are similarities
|
| 64 |
sentence_graph = nx.from_numpy_array(similarity_matrix)
|