Spaces:
Running
Running
michaelkri commited on
Commit ·
76cc805
1
Parent(s): 068f946
HDBSCAN bug fix
Browse files- app/summarizer.py +6 -0
app/summarizer.py
CHANGED
|
@@ -27,6 +27,12 @@ class Summarizer:
|
|
| 27 |
|
| 28 |
|
| 29 |
def cluster_sentences(self, sentences, embeddings, min_cluster_size=2):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
hdb = HDBSCAN(min_cluster_size=min_cluster_size).fit(embeddings)
|
| 31 |
|
| 32 |
clusters = {}
|
|
|
|
| 27 |
|
| 28 |
|
| 29 |
def cluster_sentences(self, sentences, embeddings, min_cluster_size=2):
|
| 30 |
+
# HDBSCAN requires more than one sentence
|
| 31 |
+
if not sentences:
|
| 32 |
+
return []
|
| 33 |
+
if len(sentences) == 1:
|
| 34 |
+
return [[(sentences[0], embeddings[0])]]
|
| 35 |
+
|
| 36 |
hdb = HDBSCAN(min_cluster_size=min_cluster_size).fit(embeddings)
|
| 37 |
|
| 38 |
clusters = {}
|