Spaces:
Running
Running
juhoinkinen
commited on
Decreasing order of suggestions; narrower column of bars
Browse files
app.py
CHANGED
@@ -51,9 +51,10 @@ def process(image, project_num: int, lang: str = "eng"):
|
|
51 |
|
52 |
results = annif.suggest(project_id=proj_ids[project_num], text=text)
|
53 |
|
54 |
-
# Prepare data for plotting
|
55 |
-
|
56 |
-
|
|
|
57 |
|
58 |
# Create a horizontal bar plot
|
59 |
fig = go.Figure()
|
@@ -86,6 +87,7 @@ def process(image, project_num: int, lang: str = "eng"):
|
|
86 |
),
|
87 |
margin=dict(l=10, r=120, t=40, b=10), # Increase right margin for labels
|
88 |
height=400,
|
|
|
89 |
plot_bgcolor='white',
|
90 |
)
|
91 |
|
@@ -105,6 +107,7 @@ def process(image, project_num: int, lang: str = "eng"):
|
|
105 |
except Exception as e:
|
106 |
return str(e), None
|
107 |
|
|
|
108 |
langs = ("eng", "fin", "swe")
|
109 |
|
110 |
|
|
|
51 |
|
52 |
results = annif.suggest(project_id=proj_ids[project_num], text=text)
|
53 |
|
54 |
+
# Prepare data for plotting and sort in decreasing order of scores
|
55 |
+
sorted_results = sorted(results, key=lambda x: x['score'], reverse=True)
|
56 |
+
labels = [res['label'] for res in sorted_results]
|
57 |
+
scores = [res['score'] for res in sorted_results]
|
58 |
|
59 |
# Create a horizontal bar plot
|
60 |
fig = go.Figure()
|
|
|
87 |
),
|
88 |
margin=dict(l=10, r=120, t=40, b=10), # Increase right margin for labels
|
89 |
height=400,
|
90 |
+
width=500, # Set a fixed width to make the plot narrower
|
91 |
plot_bgcolor='white',
|
92 |
)
|
93 |
|
|
|
107 |
except Exception as e:
|
108 |
return str(e), None
|
109 |
|
110 |
+
|
111 |
langs = ("eng", "fin", "swe")
|
112 |
|
113 |
|