hotchpotch commited on
Commit
6defcba
·
1 Parent(s): 05edb6c
Files changed (1) hide show
  1. app.py +11 -14
app.py CHANGED
@@ -42,35 +42,32 @@ def main():
42
 
43
  st.title("SPLADE 日本語 demo")
44
 
 
 
45
  st.markdown("""
46
- ### 入力
47
- 以下のテキストエリアに解析したいテキストを入力してください。
48
  """)
49
 
50
- input_text = st.text_area("テキスト入力", height=200)
51
 
52
- if st.button("解析開始"):
53
  if input_text.strip():
54
- with st.spinner("解析中..."):
55
  sorted_tokens = get_token_values_sorted(input_text)
56
 
57
- st.success("解析が完了しました。")
58
-
59
- st.markdown("### 結果")
60
  if sorted_tokens:
61
  formatted_data = [
62
- {"頻度": freq, "単語": word} for freq, word in sorted_tokens
 
63
  ]
64
  st.table(formatted_data)
65
  else:
66
  st.warning("入力テキストから有効な単語が見つかりませんでした。")
67
  else:
68
  st.warning("テキストを入力してください。")
69
- else:
70
- get_embedder()
71
-
72
- st.markdown("---")
73
- st.markdown("© 2024 SPLADE 日本語 demo")
74
 
75
 
76
  if __name__ == "__main__":
 
42
 
43
  st.title("SPLADE 日本語 demo")
44
 
45
+ get_embedder()
46
+
47
  st.markdown("""
48
+ [hotchpotch/japanese-splade-base-v1](https://huggingface.co/hotchpotch/japanese-splade-base-v1)を使って、テキストからSPLADEのスパースベクトルに変換するデモです。
49
+
50
  """)
51
 
52
+ input_text = st.text_area("テキスト", height=200)
53
 
54
+ if st.button("変換"):
55
  if input_text.strip():
56
+ with st.spinner("変換中..."):
57
  sorted_tokens = get_token_values_sorted(input_text)
58
 
59
+ total_tokens = len(sorted_tokens)
60
+ st.markdown(f"### 結果 (トークン数: {total_tokens})")
 
61
  if sorted_tokens:
62
  formatted_data = [
63
+ {"スコア": freq, "単語(vocab)": word}
64
+ for freq, word in sorted_tokens
65
  ]
66
  st.table(formatted_data)
67
  else:
68
  st.warning("入力テキストから有効な単語が見つかりませんでした。")
69
  else:
70
  st.warning("テキストを入力してください。")
 
 
 
 
 
71
 
72
 
73
  if __name__ == "__main__":