Spaces:
Runtime error
Runtime error
Commit
โข
4c192ae
1
Parent(s):
9e55db6
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import streamlit as st
|
|
3 |
from streamlit_lottie import st_lottie
|
4 |
import torch
|
5 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
|
|
6 |
|
7 |
# Page Config
|
8 |
st.set_page_config(
|
@@ -164,7 +165,7 @@ row1_spacer1, row1_1, row1_spacer2 = st.columns((0.01, 0.01, 0.01))
|
|
164 |
|
165 |
with row1_1:
|
166 |
st.markdown("### nํ์ ๊ฐ์ด๋๋ผ์ธ")
|
167 |
-
st.markdown("1. ํ๋จ์ ์๋ ํ
์คํธ๋ฐ์ 5์ ์ดํ ๋จ์ด๋ฅผ ๋ฃ์ด์ฃผ์ธ์")
|
168 |
st.markdown("2. 'nํ์ ์ ์ํ๊ธฐ' ๋ฒํผ์ ํด๋ฆญํด์ฃผ์ธ์")
|
169 |
|
170 |
st.write('---')
|
@@ -175,15 +176,20 @@ row2_spacer1, row2_1, row2_spacer2= st.columns((0.01, 0.01, 0.01))
|
|
175 |
# Word Input
|
176 |
with row2_1:
|
177 |
word_input = st.text_input(
|
178 |
-
"nํ์์ ์ฌ์ฉํ ๋จ์ด๋ฅผ ์ ๊ณ ๋ฒํผ์ ๋๋ฌ์ฃผ์ธ์.(์ต๋ 5์) ๐",
|
179 |
placeholder='ํ๊ธ ๋จ์ด๋ฅผ ์
๋ ฅํด์ฃผ์ธ์',
|
180 |
max_chars=5
|
181 |
)
|
|
|
182 |
|
183 |
if st.button('nํ์ ์ ์ํ๊ธฐ'):
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
st.
|
|
|
|
|
|
|
|
|
|
3 |
from streamlit_lottie import st_lottie
|
4 |
import torch
|
5 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
6 |
+
import re
|
7 |
|
8 |
# Page Config
|
9 |
st.set_page_config(
|
|
|
165 |
|
166 |
with row1_1:
|
167 |
st.markdown("### nํ์ ๊ฐ์ด๋๋ผ์ธ")
|
168 |
+
st.markdown("1. ํ๋จ์ ์๋ ํ
์คํธ๋ฐ์ 5์ ์ดํ ํ๊ธ ๋จ์ด๋ฅผ ๋ฃ์ด์ฃผ์ธ์")
|
169 |
st.markdown("2. 'nํ์ ์ ์ํ๊ธฐ' ๋ฒํผ์ ํด๋ฆญํด์ฃผ์ธ์")
|
170 |
|
171 |
st.write('---')
|
|
|
176 |
# Word Input
|
177 |
with row2_1:
|
178 |
word_input = st.text_input(
|
179 |
+
"nํ์์ ์ฌ์ฉํ ํ๊ธ ๋จ์ด๋ฅผ ์ ๊ณ ๋ฒํผ์ ๋๋ฌ์ฃผ์ธ์.(์ต๋ 5์) ๐",
|
180 |
placeholder='ํ๊ธ ๋จ์ด๋ฅผ ์
๋ ฅํด์ฃผ์ธ์',
|
181 |
max_chars=5
|
182 |
)
|
183 |
+
word_input = re.sub("[^๊ฐ-ํฃ]", "", word_input)
|
184 |
|
185 |
if st.button('nํ์ ์ ์ํ๊ธฐ'):
|
186 |
+
if word_input == "":
|
187 |
+
st.error("์จ์ ํ ํ๊ธ ๋จ์ด๋ฅผ ์ฌ์ฉํด์ฃผ์ธ์!")
|
188 |
+
|
189 |
+
else:
|
190 |
+
st.write("nํ์ ๋จ์ด : ", word_input)
|
191 |
+
with st.spinner('์ ์ ๊ธฐ๋ค๋ ค์ฃผ์ธ์...'):
|
192 |
+
result = n_line_poem(word_input)
|
193 |
+
st.success('์๋ฃ๋์ต๋๋ค!')
|
194 |
+
for r in result:
|
195 |
+
st.write(f'{r} : {result[r]}')
|