File size: 2,535 Bytes
97054aa
 
 
 
 
 
9fc7514
97054aa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9fc7514
 
97054aa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import dash_mantine_components as dmc
from dash_extensions.enrich import (Dash, DashBlueprint, Input, Output, State,
                                    dcc, exceptions, html)
from topicwizard.widgets import (ConceptClusters, DocumentClusters,
                                 TopicBrowser, TopicHierarchy,
                                 create_widget_container)
from turftopic.data import TopicData


def create_app(blueprint):
    app = Dash(
        __name__,
        blueprint=blueprint,
        title="topicwizard",
        external_scripts=[
            {
                "src": "https://cdn.tailwindcss.com",
            },
            {
                "src": "https://kit.fontawesome.com/9640e5cd85.js",
                "crossorigin": "anonymous",
            },
        ],
    )
    return app


keynmf_data = TopicData.from_disk("keynmf_data.joblib")
top2vec_data = TopicData.from_disk("top2vec_data.joblib")
print("Building blueprints.")
keynmf_blueprint = create_widget_container(
    [TopicBrowser(), ConceptClusters(), TopicHierarchy()],
    keynmf_data,
    app_id="keynmf",
)
top2vec_blueprint = create_widget_container(
    [TopicBrowser(), DocumentClusters(), TopicHierarchy()],
    top2vec_data,
    app_id="top2vec",
)

app_blueprint = DashBlueprint()
app_blueprint.layout = html.Div(
    dmc.Group(
        [
            html.Div(
                [
                    dmc.Text(
                        "KeyNMF",
                        size="xl",
                        fw=700,
                        color="blue.9",
                        align="center",
                        className="pt-8",
                    ),
                    keynmf_blueprint.layout,
                ],
                className="h-full flex-1 items-center",
            ),
            html.Div(
                [
                    dmc.Text(
                        "Top2Vec",
                        size="xl",
                        fw=700,
                        color="teal.9",
                        align="center",
                        className="pt-8",
                    ),
                    top2vec_blueprint.layout,
                ],
                className="h-full flex-1 items-center",
            ),
        ],
        grow=True,
        className="h-full flex-1",
    ),
    className="""
        w-full h-full flex-col flex items-stretch fixed
        bg-white
    """,
)

app = create_app(app_blueprint)
server = app.server

if __name__ == "__main__":
    app.run_server(debug=False, port=7860)