Spaces:
Sleeping
Sleeping
Upload 61 files
Browse files
app.py
CHANGED
@@ -183,14 +183,14 @@ if st.session_state.button_clicked:
|
|
183 |
if selected_character in top_categories:
|
184 |
selected_character_index = top_categories.index(selected_character)
|
185 |
if selected_character_index == 0:
|
186 |
-
result_text = "
|
187 |
elif selected_character_index in [1, 2]:
|
188 |
-
result_text = "
|
189 |
else:
|
190 |
-
result_text = "
|
191 |
else:
|
192 |
# リストにキャラクターがない場合
|
193 |
-
result_text = "
|
194 |
st.session_state.result_text = result_text
|
195 |
|
196 |
# 結果の表示
|
@@ -365,21 +365,32 @@ if st.session_state.button_clicked:
|
|
365 |
similar_sentences, mentioned_sentences = process_input(character_index, input_sentence, characters_list)
|
366 |
|
367 |
with st.container():
|
368 |
-
st.subheader("
|
369 |
# 類似度の閾値
|
370 |
-
|
|
|
|
|
371 |
# 類似度の高い台詞をDataFrameに変換
|
372 |
similar_df = pd.DataFrame(similar_sentences, columns=['台詞', '類似度'])
|
|
|
373 |
# 閾値より上のデータが存在するかどうかをチェック
|
374 |
-
if not similar_df[similar_df['類似度'] >=
|
375 |
-
#
|
376 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
377 |
# 閾値より下のデータが存在するかどうかをチェック
|
378 |
-
if not similar_df[similar_df['類似度'] <
|
379 |
# 閾値より下のデータが存在する場合、警告メッセージを表示
|
380 |
-
st.markdown("<span style='color:red;'
|
381 |
# 閾値より下のデータを表示
|
382 |
-
st.dataframe(similar_df[similar_df['類似度'] <
|
383 |
with tab3:
|
384 |
with st.container():
|
385 |
# キーワードのリストを取得
|
|
|
183 |
if selected_character in top_categories:
|
184 |
selected_character_index = top_categories.index(selected_character)
|
185 |
if selected_character_index == 0:
|
186 |
+
result_text = "🙆 14キャラクターの中でも一番近い話体と出ています。"
|
187 |
elif selected_character_index in [1, 2]:
|
188 |
+
result_text = "👍 14キャラクターの中でも3位以内に入るくらい話体が妥当です。"
|
189 |
else:
|
190 |
+
result_text = "❓ 話体が不適切な可能性があります。類似話題を確認して修正しましょう。"
|
191 |
else:
|
192 |
# リストにキャラクターがない場合
|
193 |
+
result_text = "❓ リストにキャラクターがない場合"
|
194 |
st.session_state.result_text = result_text
|
195 |
|
196 |
# 結果の表示
|
|
|
365 |
similar_sentences, mentioned_sentences = process_input(character_index, input_sentence, characters_list)
|
366 |
|
367 |
with st.container():
|
368 |
+
st.subheader("類似話題:")
|
369 |
# 類似度の閾値
|
370 |
+
high_similarity_threshold = 0.9
|
371 |
+
moderate_similarity_threshold = 0.85
|
372 |
+
|
373 |
# 類似度の高い台詞をDataFrameに変換
|
374 |
similar_df = pd.DataFrame(similar_sentences, columns=['台詞', '類似度'])
|
375 |
+
|
376 |
# 閾値より上のデータが存在するかどうかをチェック
|
377 |
+
if not similar_df[similar_df['類似度'] >= high_similarity_threshold].empty:
|
378 |
+
# 0.9以上の類似度の高い話題がある場合のメッセージ
|
379 |
+
st.markdown("🙆 類似度の高い話題があります。参考にしてください。")
|
380 |
+
elif not similar_df[similar_df['類似度'] >= moderate_similarity_threshold].empty:
|
381 |
+
# 0.9以上の類似度はないが、0.85以上の類似度がある場合のメッセージ
|
382 |
+
st.markdown("👍 類似度が高めの話題があります。")
|
383 |
+
|
384 |
+
# 0.85以上の類似度を持つ話題を表示(閾値より下のデータは除外)
|
385 |
+
if not similar_df[similar_df['類似度'] >= moderate_similarity_threshold].empty:
|
386 |
+
st.dataframe(similar_df[similar_df['類似度'] >= moderate_similarity_threshold].reset_index(drop=True).style.format({'類似度': "{:.2f}"}))
|
387 |
+
|
388 |
# 閾値より下のデータが存在するかどうかをチェック
|
389 |
+
if not similar_df[similar_df['類似度'] < moderate_similarity_threshold].empty:
|
390 |
# 閾値より下のデータが存在する場合、警告メッセージを表示
|
391 |
+
st.markdown("<span style='color:red;'>❗ 以下、類似度が低くあまり参考にならない可能性があります。</span>", unsafe_allow_html=True)
|
392 |
# 閾値より下のデータを表示
|
393 |
+
st.dataframe(similar_df[similar_df['類似度'] < moderate_similarity_threshold].reset_index(drop=True).style.format({'類似度': "{:.2f}"}))
|
394 |
with tab3:
|
395 |
with st.container():
|
396 |
# キーワードのリストを取得
|