File size: 694 Bytes
12df9bd
 
 
7d1ea55
12df9bd
 
7d1ea55
 
 
 
 
12df9bd
 
 
7d1ea55
 
 
 
 
 
12df9bd
 
7d1ea55
 
 
 
 
 
12df9bd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import plotly.graph_objects as go

def build_cluster_graph(results, clusters):
    xs, ys, labels = [], [], []

    i = 0
    for agency, docs in clusters.items():
        for d in docs:
            xs.append(i)
            ys.append(len(docs))
            labels.append(f"{agency}: {d['title']}")
            i += 1

    fig = go.Figure(
        go.Scatter(
            x=xs,
            y=ys,
            mode="markers",
            text=labels,
            marker=dict(size=10),
        )
    )

    fig.update_layout(
        title="Semantic Cluster Graph (Click nodes to inspect documents)",
        xaxis_title="Document Index",
        yaxis_title="Cluster Density",
    )
    return fig