Update app.py
Browse files
app.py
CHANGED
@@ -311,30 +311,9 @@ def main():
|
|
311 |
st.subheader("Semantic Network")
|
312 |
semantic_graph = analyzer.create_semantic_network(text)
|
313 |
|
314 |
-
# Convert NetworkX graph to Plotly
|
315 |
-
edge_x = []
|
316 |
-
edge_y = []
|
317 |
-
node_x = []
|
318 |
-
node_y = []
|
319 |
-
node_text = []
|
320 |
-
|
321 |
-
# Add edges
|
322 |
-
for edge in semantic_graph.edges():
|
323 |
-
x0, y0 = semantic_graph.nodes[edge[0]]['pos']
|
324 |
-
x1, y1 = semantic_graph.nodes[edge[1]]['pos']
|
325 |
-
edge_x.extend([x0, x1, None])
|
326 |
-
edge_y.extend([y0, y1, None])
|
327 |
-
|
328 |
-
# Add nodes
|
329 |
-
for node in semantic_graph.nodes():
|
330 |
-
x, y = semantic_graph.nodes[node]['pos']
|
331 |
-
node_x.append(x)
|
332 |
-
node_y.append(y)
|
333 |
-
node_text.append(node)
|
334 |
-
|
335 |
# Create the network visualization
|
336 |
network_fig = go.Figure()
|
337 |
-
|
338 |
# Add edges with varying widths
|
339 |
for edge in semantic_graph.edges():
|
340 |
x0, y0 = semantic_graph.nodes[edge[0]]['pos']
|
@@ -348,7 +327,7 @@ def main():
|
|
348 |
line=dict(width=width, color='#888'),
|
349 |
hoverinfo='none'
|
350 |
))
|
351 |
-
|
352 |
# Add nodes with varying sizes
|
353 |
for node in semantic_graph.nodes():
|
354 |
x, y = semantic_graph.nodes[node]['pos']
|
@@ -358,20 +337,26 @@ def main():
|
|
358 |
x=[x],
|
359 |
y=[y],
|
360 |
mode='markers+text',
|
361 |
-
marker=dict(
|
|
|
|
|
|
|
|
|
362 |
text=[node],
|
363 |
textposition="top center",
|
364 |
hoverinfo='text'
|
365 |
))
|
366 |
-
|
367 |
network_fig.update_layout(
|
368 |
showlegend=False,
|
369 |
hovermode='closest',
|
370 |
margin=dict(b=0,l=0,r=0,t=0),
|
371 |
xaxis=dict(showgrid=False, zeroline=False, showticklabels=False),
|
372 |
-
yaxis=dict(showgrid=False, zeroline=False, showticklabels=False)
|
|
|
373 |
)
|
374 |
-
|
|
|
375 |
with tab5:
|
376 |
st.subheader("Advanced NLP Analysis")
|
377 |
|
|
|
311 |
st.subheader("Semantic Network")
|
312 |
semantic_graph = analyzer.create_semantic_network(text)
|
313 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
314 |
# Create the network visualization
|
315 |
network_fig = go.Figure()
|
316 |
+
|
317 |
# Add edges with varying widths
|
318 |
for edge in semantic_graph.edges():
|
319 |
x0, y0 = semantic_graph.nodes[edge[0]]['pos']
|
|
|
327 |
line=dict(width=width, color='#888'),
|
328 |
hoverinfo='none'
|
329 |
))
|
330 |
+
|
331 |
# Add nodes with varying sizes
|
332 |
for node in semantic_graph.nodes():
|
333 |
x, y = semantic_graph.nodes[node]['pos']
|
|
|
337 |
x=[x],
|
338 |
y=[y],
|
339 |
mode='markers+text',
|
340 |
+
marker=dict(
|
341 |
+
size=10 + size/2,
|
342 |
+
color='#1f77b4',
|
343 |
+
line=dict(width=2, color='white')
|
344 |
+
),
|
345 |
text=[node],
|
346 |
textposition="top center",
|
347 |
hoverinfo='text'
|
348 |
))
|
349 |
+
|
350 |
network_fig.update_layout(
|
351 |
showlegend=False,
|
352 |
hovermode='closest',
|
353 |
margin=dict(b=0,l=0,r=0,t=0),
|
354 |
xaxis=dict(showgrid=False, zeroline=False, showticklabels=False),
|
355 |
+
yaxis=dict(showgrid=False, zeroline=False, showticklabels=False),
|
356 |
+
plot_bgcolor='white'
|
357 |
)
|
358 |
+
|
359 |
+
st.plotly_chart(network_fig)
|
360 |
with tab5:
|
361 |
st.subheader("Advanced NLP Analysis")
|
362 |
|