21iridescent commited on
Commit
7b5bc01
·
1 Parent(s): 2426b46

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +79 -0
app.py ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from auto_gene import read_txt, random_gene, random_gene_words
3
+ from replace_nlp import change_sentence
4
+ from dict import get_batch_idioms
5
+ # streamlit run run.py
6
+ # markdown
7
+
8
+ from PIL import Image
9
+ #image1 = Image.open('WX20220528-134651@2x.png')
10
+ # 设置网页标题
11
+ st.title('《献礼工程》 -- 电子诗人')
12
+
13
+ #st.image(image1)
14
+
15
+ # 展示一级标题
16
+ #st.subheader('献礼工程')
17
+
18
+ #image2 = Image.open('v2-3420614c84c85bba28ec098d771fb27d_1440w.jpg')
19
+
20
+ with st.sidebar:
21
+ add_radio = st.radio(
22
+ '你想要:',
23
+ ("电子唱诗", "来点儿词汇")
24
+ )
25
+
26
+ if add_radio == "电子唱诗":
27
+
28
+ lucky_num = st.slider('选择你的幸运数字吧!', min_value=0, max_value=100, value=50,
29
+ step=1)
30
+
31
+ crazy_level = st.slider('癫狂程度 【0 分清醒 - 100 分疯狂】', min_value=0.00, max_value=1.00, value=0.5,
32
+ step=0.01)
33
+
34
+ if st.button('我要献礼!'):
35
+ with st.spinner("生成中........"):
36
+
37
+ st.balloons()
38
+
39
+ result = read_txt('存档.txt')
40
+ text = random_gene(lucky_num, result)
41
+ text = list(filter(None, text))
42
+ count = 0
43
+ for i in text:
44
+ #st.success(text)
45
+ text = change_sentence(i, lucky_num+count, crazy_level)
46
+ st.markdown(text)
47
+ count = count + 1
48
+ else:
49
+ st.warning('还没献礼呢!')
50
+
51
+ elif "来点儿词汇":
52
+
53
+ lucky_num = st.slider('选择你的幸运数字吧!', min_value=0, max_value=100, value=50,
54
+ step=1)
55
+
56
+ if st.button('我要献礼!'):
57
+ with st.spinner("生成中........"):
58
+
59
+ st.balloons()
60
+
61
+ result = read_txt('存档.txt')
62
+ a, b, c , d= random_gene_words(lucky_num)
63
+ e = get_batch_idioms()
64
+ st.subheader(a)
65
+ st.subheader(b)
66
+ st.subheader(c)
67
+ st.subheader(d)
68
+ st.subheader(e)
69
+ #for i in text:
70
+ # st.success(text)
71
+ #st.markdown(i)
72
+
73
+ else:
74
+ st.write('还没献礼')
75
+
76
+
77
+
78
+
79
+ #st.image(image2)