Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -50,12 +50,10 @@ def load_jsonl(jsonl_file):
|
|
| 50 |
except:
|
| 51 |
pass
|
| 52 |
|
| 53 |
-
# build clusters
|
| 54 |
cluster_map = defaultdict(list)
|
| 55 |
for r in records:
|
| 56 |
cluster_map[r.get("cluster", -1)].append(r)
|
| 57 |
|
| 58 |
-
# build BM25
|
| 59 |
docs_text = [r["text"] for r in records]
|
| 60 |
tokenized_docs = [tokenize(t) for t in docs_text]
|
| 61 |
|
|
@@ -67,7 +65,6 @@ def load_jsonl(jsonl_file):
|
|
| 67 |
Ndocs = len(records)
|
| 68 |
avg_len = sum(len(t) for t in tokenized_docs) / Ndocs
|
| 69 |
|
| 70 |
-
# Precompute centroids
|
| 71 |
centroids = {cid: centroid(docs) for cid, docs in cluster_map.items()}
|
| 72 |
|
| 73 |
return {
|
|
@@ -194,9 +191,11 @@ def do_entity_search(state, name):
|
|
| 194 |
# GRADIO UI
|
| 195 |
# ===============================================================
|
| 196 |
|
| 197 |
-
with gr.Blocks(title="Epstein Semantic Explorer
|
| 198 |
-
gr.Markdown("
|
| 199 |
-
|
|
|
|
|
|
|
| 200 |
|
| 201 |
with gr.Row():
|
| 202 |
jsonl_file = gr.File(label="Upload JSONL dataset")
|
|
@@ -216,4 +215,4 @@ Upload your `epstein_semantic.jsonl` file.")
|
|
| 216 |
|
| 217 |
gr.Button("Show Topics").click(do_show_topics, inputs=[state], outputs=output)
|
| 218 |
|
| 219 |
-
demo.launch()
|
|
|
|
| 50 |
except:
|
| 51 |
pass
|
| 52 |
|
|
|
|
| 53 |
cluster_map = defaultdict(list)
|
| 54 |
for r in records:
|
| 55 |
cluster_map[r.get("cluster", -1)].append(r)
|
| 56 |
|
|
|
|
| 57 |
docs_text = [r["text"] for r in records]
|
| 58 |
tokenized_docs = [tokenize(t) for t in docs_text]
|
| 59 |
|
|
|
|
| 65 |
Ndocs = len(records)
|
| 66 |
avg_len = sum(len(t) for t in tokenized_docs) / Ndocs
|
| 67 |
|
|
|
|
| 68 |
centroids = {cid: centroid(docs) for cid, docs in cluster_map.items()}
|
| 69 |
|
| 70 |
return {
|
|
|
|
| 191 |
# GRADIO UI
|
| 192 |
# ===============================================================
|
| 193 |
|
| 194 |
+
with gr.Blocks(title="Epstein Semantic Explorer") as demo:
|
| 195 |
+
gr.Markdown("""
|
| 196 |
+
# Epstein Semantic Explorer
|
| 197 |
+
Upload your `epstein_semantic.jsonl` file to begin.
|
| 198 |
+
""")
|
| 199 |
|
| 200 |
with gr.Row():
|
| 201 |
jsonl_file = gr.File(label="Upload JSONL dataset")
|
|
|
|
| 215 |
|
| 216 |
gr.Button("Show Topics").click(do_show_topics, inputs=[state], outputs=output)
|
| 217 |
|
| 218 |
+
demo.launch()
|