Spaces:
Sleeping
Sleeping
Delete cluster.py
Browse files- cluster.py +0 -12
cluster.py
DELETED
|
@@ -1,12 +0,0 @@
|
|
| 1 |
-
from typing import List, Dict
|
| 2 |
-
from core.faiss_vector import FaissIndex
|
| 3 |
-
|
| 4 |
-
def cluster_results(results: List[dict], k: int = 5) -> Dict[str, List[dict]]:
|
| 5 |
-
texts = [r.get("snippet","") for r in results if r.get("snippet")]
|
| 6 |
-
index = FaissIndex()
|
| 7 |
-
index.add(texts)
|
| 8 |
-
clusters = {}
|
| 9 |
-
for r in results:
|
| 10 |
-
key = r.get("source","Unknown")
|
| 11 |
-
clusters.setdefault(key, []).append(r)
|
| 12 |
-
return clusters
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|