jonghhhh commited on
Commit
577ec3b
ยท
verified ยท
1 Parent(s): ca02078

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -0
app.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+
4
+ # ์„ค๋ฌธ ์ œ๋ชฉ
5
+ st.title("์‹ค์‹œ๊ฐ„ ์ˆ˜์—… ์„ค๋ฌธ์กฐ์‚ฌ")
6
+
7
+ # ์„ค๋ฌธ ์งˆ๋ฌธ ์ž…๋ ฅ
8
+ question = st.text_input("์„ค๋ฌธ ์งˆ๋ฌธ์„ ์ž…๋ ฅํ•˜์„ธ์š”:")
9
+
10
+ # ์„ ํƒํ˜• ๋‹ต๋ณ€ ํ•ญ๋ชฉ ์ž…๋ ฅ
11
+ options = st.text_area("์„ ํƒํ˜• ๋‹ต๋ณ€ ํ•ญ๋ชฉ์„ ์ž…๋ ฅํ•˜์„ธ์š” (๊ฐ ํ•ญ๋ชฉ์„ ์ƒˆ ์ค„์— ์ž…๋ ฅ):").split('\n')
12
+
13
+ # ์ฃผ๊ด€์‹ ๋‹ต๋ณ€ ์ž…๋ ฅ ํ™œ์„ฑํ™”
14
+ open_ended = st.checkbox("์ฃผ๊ด€์‹ ๋‹ต๋ณ€๋„ ํ—ˆ์šฉํ•˜๊ธฐ")
15
+
16
+ # ๋‹ต๋ณ€ ์ˆ˜์ง‘
17
+ if question and options:
18
+ st.write("### ์„ค๋ฌธ ์ฐธ์—ฌ")
19
+ selected_option = st.radio(question, options)
20
+
21
+ if open_ended:
22
+ open_answer = st.text_input("๊ธฐํƒ€ ์˜๊ฒฌ์ด ์žˆ์œผ๋ฉด ์ž…๋ ฅํ•˜์„ธ์š”:")
23
+
24
+ # ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ๋‹ต๋ณ€ ์ œ์ถœ
25
+ if st.button("๋‹ต๋ณ€ ์ œ์ถœ"):
26
+ # ์„ ํƒํ˜• ๋‹ต๋ณ€ ์ €์žฅ
27
+ if 'responses' not in st.session_state:
28
+ st.session_state['responses'] = []
29
+
30
+ st.session_state['responses'].append({'์„ ํƒ': selected_option, '์ฃผ๊ด€์‹': open_answer if open_ended else None})
31
+
32
+ # ๋‹ต๋ณ€ ๊ฒฐ๊ณผ ํ‘œ์‹œ
33
+ if 'responses' in st.session_state:
34
+ st.write("### ์„ค๋ฌธ ๊ฒฐ๊ณผ")
35
+ df = pd.DataFrame(st.session_state['responses'])
36
+
37
+ if not df.empty:
38
+ st.write("#### ์„ ํƒํ˜• ๋‹ต๋ณ€ ๋ถ„ํฌ")
39
+ st.bar_chart(df['์„ ํƒ'].value_counts()) # ์„ ํƒํ˜• ๋‹ต๋ณ€ ๋นˆ๋„๋ฅผ ๋ง‰๋Œ€๊ทธ๋ž˜ํ”„๋กœ ํ‘œ์‹œ
40
+
41
+ if open_ended:
42
+ st.write("#### ์ฃผ๊ด€์‹ ๋‹ต๋ณ€")
43
+ st.table(df['์ฃผ๊ด€์‹'].dropna()) # ์ฃผ๊ด€์‹ ๋‹ต๋ณ€์„ ํ…Œ์ด๋ธ”๋กœ ํ‘œ์‹œ
44
+
45
+ # ๋ฆฌ์…‹ ๋ฒ„ํŠผ
46
+ if st.button("์„ค๋ฌธ ์ดˆ๊ธฐํ™”"):
47
+ st.session_state['responses'] = []
48
+ st.experimental_rerun()