Update app.py
Browse files
app.py
CHANGED
@@ -27,14 +27,15 @@ query = st_keyup(
|
|
27 |
)
|
28 |
|
29 |
if query != "" and is_hiragana_or_katakana(query):
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
39 |
else:
|
40 |
st.info("ひらがな/カタカナのみを入力してください")
|
|
|
27 |
)
|
28 |
|
29 |
if query != "" and is_hiragana_or_katakana(query):
|
30 |
+
if query in query_candidates:
|
31 |
+
top_candidates, top_losses = query_candidates[query]
|
32 |
+
else:
|
33 |
+
# top_candidates = [query]
|
34 |
+
# top_losses = [0.0]
|
35 |
+
top_candidates, top_losses = search_candidates(query, query_candidates, model=model, tokenizer=tokenizer, top_k=100)
|
36 |
+
answers = ["{}: {:.2f}".format(top_candidates[index], top_losses[index]) for index in range(min(len(top_candidates), 10))]
|
37 |
+
value = "\n".join(answers)
|
38 |
+
value += f"\n({len(top_candidates)}候補)"
|
39 |
+
st.info(value)
|
40 |
else:
|
41 |
st.info("ひらがな/カタカナのみを入力してください")
|