Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
# Copyright 2023 Dmitry Ustalov
|
2 |
#
|
3 |
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -27,6 +29,7 @@ import gradio as gr
|
|
27 |
import matplotlib.pyplot as plt
|
28 |
import networkx as nx
|
29 |
import pandas as pd
|
|
|
30 |
|
31 |
if 'MCL_BIN' in os.environ and os.path.isfile(os.environ['MCL_BIN']) and os.access(os.environ['MCL_BIN'], os.X_OK):
|
32 |
MCL: Optional[str] = os.environ['MCL_BIN']
|
@@ -107,7 +110,7 @@ SENSE = re.compile(r'^(?P<item>\d+)#(?P<sense>\d+)$')
|
|
107 |
|
108 |
|
109 |
# noinspection PyPep8Naming
|
110 |
-
def visualize(G: nx.Graph, seed: int = 0) ->
|
111 |
pos = nx.spring_layout(G, seed=seed)
|
112 |
|
113 |
fig = plt.figure(dpi=240)
|
@@ -161,7 +164,7 @@ def watset(G: nx.Graph, algorithm: str, seed: int = 0,
|
|
161 |
return df_clusters, None
|
162 |
|
163 |
|
164 |
-
def handler(file: IO[bytes], algorithm: str, seed: int) -> Tuple[pd.DataFrame,
|
165 |
if file is None:
|
166 |
raise gr.Error('File must be uploaded')
|
167 |
|
|
|
1 |
+
#!/usr/bin/env python3
|
2 |
+
|
3 |
# Copyright 2023 Dmitry Ustalov
|
4 |
#
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
29 |
import matplotlib.pyplot as plt
|
30 |
import networkx as nx
|
31 |
import pandas as pd
|
32 |
+
from matplotlib.pyplot import Figure # type: ignore[attr-defined]
|
33 |
|
34 |
if 'MCL_BIN' in os.environ and os.path.isfile(os.environ['MCL_BIN']) and os.access(os.environ['MCL_BIN'], os.X_OK):
|
35 |
MCL: Optional[str] = os.environ['MCL_BIN']
|
|
|
110 |
|
111 |
|
112 |
# noinspection PyPep8Naming
|
113 |
+
def visualize(G: nx.Graph, seed: int = 0) -> Figure:
|
114 |
pos = nx.spring_layout(G, seed=seed)
|
115 |
|
116 |
fig = plt.figure(dpi=240)
|
|
|
164 |
return df_clusters, None
|
165 |
|
166 |
|
167 |
+
def handler(file: IO[bytes], algorithm: str, seed: int) -> Tuple[pd.DataFrame, Figure]:
|
168 |
if file is None:
|
169 |
raise gr.Error('File must be uploaded')
|
170 |
|