isonuma commited on
Commit
a13e156
·
verified ·
1 Parent(s): e59d7bb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -27,14 +27,15 @@ query = st_keyup(
27
  )
28
 
29
  if query != "" and is_hiragana_or_katakana(query):
30
- st.info("OK")
31
- # if query in query_candidates:
32
- # top_candidates, top_losses = query_candidates[query]
33
- # else:
34
- # top_candidates, top_losses = search_candidates(query, top_k=100)
35
- # answers = ["{}: {:.2f}".format(top_candidates[index], top_losses[index]) for index in range(min(len(top_candidates), 10))]
36
- # value = "<br>".join(answers)
37
- # value += f"<br>({len(top_candidates)}候補)"
38
- # html.value = value
 
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("ひらがな/カタカナのみを入力してください")