Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -84,35 +84,64 @@ if 'similar_sentences' not in st.session_state:
|
|
| 84 |
if 'selected_index' not in st.session_state:
|
| 85 |
st.session_state.selected_index = 0
|
| 86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
# "ํ๊ฐ ์์ฑ" ๋ฒํผ ํด๋ฆญ ์์ ๋์
|
| 88 |
if st.button("ํ๊ฐ ์์ฑ"):
|
| 89 |
with st.spinner('๋ต๋ณ ์์ฑ์ค...'):
|
| 90 |
result = generate_annotated_text(achievement_standard)
|
| 91 |
-
|
| 92 |
exec(result.replace('```', ''))
|
| 93 |
|
| 94 |
-
# annotated_text ๊ฒฐ๊ณผ์์ ๋ฌธ์ฅ๋ง ์ถ์ถ
|
| 95 |
result_lines = result.split('\n')
|
| 96 |
sentences = []
|
| 97 |
for line in result_lines:
|
| 98 |
-
# "(" ๋ฌธ์์ด์ด ํฌํจ๋ ์์น๋ฅผ ์ฐพ์์ ๊ทธ ์ดํ์ ๋ฌธ์์ด๋ง ์ถ์ถ
|
| 99 |
start_idx = line.find('("')
|
| 100 |
if start_idx != -1:
|
| 101 |
end_idx = line.find('",', start_idx)
|
| 102 |
-
sentence = line[start_idx + 2:end_idx].strip()
|
| 103 |
sentences.append(sentence)
|
| 104 |
|
|
|
|
|
|
|
| 105 |
|
| 106 |
-
# ๋ฌธ์ฅ์ ๋ผ๋์ค ๋ฒํผ์ผ๋ก ํ์ ๋ฐ ์ ํ๋ ๋ฌธ์ฅ ์ ์ฅ
|
| 107 |
-
selected_index = st.radio("๋ฌธ์ฅ์ ์ ํํ์ธ์:", range(len(sentences)), format_func=lambda x: sentences[x])
|
| 108 |
-
st.session_state.selected_sentence = sentences[selected_index] if sentences else None
|
| 109 |
-
|
| 110 |
-
|
| 111 |
# ์ ์ฌํ ๋ฌธ์ฅ ์์ฑ ๋ฒํผ ์ถ๊ฐ
|
| 112 |
if st.button("์ ์ฌํ ๋ฌธ๊ตฌ ์์ฑ") and st.session_state.get('selected_sentence'):
|
| 113 |
with st.spinner('๋ฌธ์ฅ ์์ฑ์ค...'):
|
| 114 |
similar_sentences = generate_similar_sentences(st.session_state.selected_sentence)
|
| 115 |
-
for
|
| 116 |
-
st.write(
|
| 117 |
-
|
| 118 |
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
if 'selected_index' not in st.session_state:
|
| 85 |
st.session_state.selected_index = 0
|
| 86 |
|
| 87 |
+
# # "ํ๊ฐ ์์ฑ" ๋ฒํผ ํด๋ฆญ ์์ ๋์
|
| 88 |
+
# if st.button("ํ๊ฐ ์์ฑ"):
|
| 89 |
+
# with st.spinner('๋ต๋ณ ์์ฑ์ค...'):
|
| 90 |
+
# result = generate_annotated_text(achievement_standard)
|
| 91 |
+
# # ๊ฒฐ๊ณผ ์ถ๋ ฅ
|
| 92 |
+
# exec(result.replace('```', ''))
|
| 93 |
+
|
| 94 |
+
# # annotated_text ๊ฒฐ๊ณผ์์ ๋ฌธ์ฅ๋ง ์ถ์ถ
|
| 95 |
+
# result_lines = result.split('\n')
|
| 96 |
+
# sentences = []
|
| 97 |
+
# for line in result_lines:
|
| 98 |
+
# # "(" ๋ฌธ์์ด์ด ํฌํจ๋ ์์น๋ฅผ ์ฐพ์์ ๊ทธ ์ดํ์ ๋ฌธ์์ด๋ง ์ถ์ถ
|
| 99 |
+
# start_idx = line.find('("')
|
| 100 |
+
# if start_idx != -1:
|
| 101 |
+
# end_idx = line.find('",', start_idx)
|
| 102 |
+
# sentence = line[start_idx + 2:end_idx].strip() # "(" ๋ค์๋ถํฐ "," ์ ๊น์ง์ ๋ฌธ์์ด์ ์ถ์ถ
|
| 103 |
+
# sentences.append(sentence)
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
# # ๋ฌธ์ฅ์ ๋ผ๋์ค ๋ฒํผ์ผ๋ก ํ์ ๋ฐ ์ ํ๋ ๋ฌธ์ฅ ์ ์ฅ
|
| 107 |
+
# selected_index = st.radio("๋ฌธ์ฅ์ ์ ํํ์ธ์:", range(len(sentences)), format_func=lambda x: sentences[x])
|
| 108 |
+
# st.session_state.selected_sentence = sentences[selected_index] if sentences else None
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
# # ์ ์ฌํ ๋ฌธ์ฅ ์์ฑ ๋ฒํผ ์ถ๊ฐ
|
| 112 |
+
# if st.button("์ ์ฌํ ๋ฌธ๊ตฌ ์์ฑ") and st.session_state.get('selected_sentence'):
|
| 113 |
+
# with st.spinner('๋ฌธ์ฅ ์์ฑ์ค...'):
|
| 114 |
+
# similar_sentences = generate_similar_sentences(st.session_state.selected_sentence)
|
| 115 |
+
# for sentence in st.session_state.similar_sentences:
|
| 116 |
+
# st.write(sentence)
|
| 117 |
+
|
| 118 |
# "ํ๊ฐ ์์ฑ" ๋ฒํผ ํด๋ฆญ ์์ ๋์
|
| 119 |
if st.button("ํ๊ฐ ์์ฑ"):
|
| 120 |
with st.spinner('๋ต๋ณ ์์ฑ์ค...'):
|
| 121 |
result = generate_annotated_text(achievement_standard)
|
| 122 |
+
st.session_state.generated_result = result
|
| 123 |
exec(result.replace('```', ''))
|
| 124 |
|
| 125 |
+
# annotated_text ๊ฒฐ๊ณผ์์ ๋ฌธ์ฅ๋ง ์ถ์ถ ๋ฐ ์
๋ ํธ ๋ฐ์ค ์ถ๊ฐ
|
| 126 |
result_lines = result.split('\n')
|
| 127 |
sentences = []
|
| 128 |
for line in result_lines:
|
|
|
|
| 129 |
start_idx = line.find('("')
|
| 130 |
if start_idx != -1:
|
| 131 |
end_idx = line.find('",', start_idx)
|
| 132 |
+
sentence = line[start_idx + 2:end_idx].strip()
|
| 133 |
sentences.append(sentence)
|
| 134 |
|
| 135 |
+
if sentences:
|
| 136 |
+
st.session_state.selected_sentence = st.selectbox("๋ฌธ์ฅ์ ์ ํํ์ธ์:", sentences)
|
| 137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
# ์ ์ฌํ ๋ฌธ์ฅ ์์ฑ ๋ฒํผ ์ถ๊ฐ
|
| 139 |
if st.button("์ ์ฌํ ๋ฌธ๊ตฌ ์์ฑ") and st.session_state.get('selected_sentence'):
|
| 140 |
with st.spinner('๋ฌธ์ฅ ์์ฑ์ค...'):
|
| 141 |
similar_sentences = generate_similar_sentences(st.session_state.selected_sentence)
|
| 142 |
+
for generated_sentence in similar_sentences:
|
| 143 |
+
st.write(generated_sentence)
|
|
|
|
| 144 |
|
| 145 |
+
# ์์ฑ๋ ๊ฒฐ๊ณผ ๋ฐ ์ ์ฌํ ๋ฌธ์ฅ๋ค ์ถ๋ ฅ
|
| 146 |
+
if st.session_state.get('generated_result'):
|
| 147 |
+
exec(st.session_state.generated_result.replace('```', ''))
|