Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -243,35 +243,35 @@ def run_entity_exploration():
|
|
243 |
if class_entities:
|
244 |
entities.extend(class_entities)
|
245 |
|
246 |
-
# Remove duplicates and sort
|
247 |
entities = sorted(set(entities))
|
248 |
|
249 |
-
# Debug
|
250 |
st.write("Loaded entities:", entities)
|
251 |
st.write("Ontology classes:", ontology_manager.get_classes())
|
252 |
for node, attr in ontology_manager.graph.nodes(data=True):
|
253 |
if attr.get("type") == "instance":
|
254 |
st.write("Found instance:", node, "of class:", attr.get("class_type"))
|
255 |
|
|
|
|
|
256 |
if entities:
|
257 |
selected_entity = st.selectbox("Select Entity", entities)
|
258 |
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
# Optional: visualize neighborhood or print debug info
|
275 |
else:
|
276 |
st.warning("No entities found in the ontology.")
|
277 |
|
|
|
243 |
if class_entities:
|
244 |
entities.extend(class_entities)
|
245 |
|
|
|
246 |
entities = sorted(set(entities))
|
247 |
|
248 |
+
# Debug info
|
249 |
st.write("Loaded entities:", entities)
|
250 |
st.write("Ontology classes:", ontology_manager.get_classes())
|
251 |
for node, attr in ontology_manager.graph.nodes(data=True):
|
252 |
if attr.get("type") == "instance":
|
253 |
st.write("Found instance:", node, "of class:", attr.get("class_type"))
|
254 |
|
255 |
+
selected_entity = None # <-- 瀹夊叏瀹e憡锛岄伩鍏嶆湭瀹氱京閷
|
256 |
+
|
257 |
if entities:
|
258 |
selected_entity = st.selectbox("Select Entity", entities)
|
259 |
|
260 |
+
if selected_entity:
|
261 |
+
entity_info = ontology_manager.get_entity_info(selected_entity)
|
262 |
+
display_entity_details(entity_info, ontology_manager)
|
263 |
|
264 |
+
if st.button("View this Entity in the Knowledge Graph"):
|
265 |
+
st.session_state.central_entity = selected_entity
|
266 |
+
st.rerun()
|
267 |
|
268 |
+
st.subheader("Entity Neighborhood")
|
269 |
+
max_distance = st.slider("Maximum Neighborhood Distance", 1, 3, 1)
|
270 |
+
neighborhood = knowledge_graph.get_entity_neighborhood(
|
271 |
+
selected_entity,
|
272 |
+
max_distance=max_distance,
|
273 |
+
include_classes=True
|
274 |
+
)
|
|
|
275 |
else:
|
276 |
st.warning("No entities found in the ontology.")
|
277 |
|