Spaces:
Running
Running
山越貴耀
commited on
Commit
·
2d56324
1
Parent(s):
0dfbcf3
fixed bugs
Browse files
app.py
CHANGED
@@ -79,7 +79,8 @@ def run_tsne(chain):
|
|
79 |
return tsne
|
80 |
|
81 |
def clear_df():
|
82 |
-
|
|
|
83 |
|
84 |
#@st.cache(show_spinner=False)
|
85 |
def plot_fig(df,sent_id,xlims,ylims,color_list):
|
@@ -165,14 +166,15 @@ if __name__=='__main__':
|
|
165 |
|
166 |
if input_type=='Use one of the example sentences':
|
167 |
sentence = st.sidebar.selectbox("Select the inital sentence",
|
168 |
-
('
|
|
|
169 |
'She grew up with three brothers and ten sisters.'))
|
170 |
-
if sentence
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
|
177 |
else:
|
178 |
sentence = st.sidebar.text_input('Type down your own sentence here.',on_change=clear_df)
|
@@ -255,12 +257,12 @@ if __name__=='__main__':
|
|
255 |
st.write(decoded_sent[-1])
|
256 |
for word_id,(col,word) in enumerate(zip(cols[1:-1],decoded_sent[1:-1])):
|
257 |
with col:
|
258 |
-
if st.button(word):
|
259 |
probs = mask_prob(model,mask_id,input_sent,word_id+1)
|
260 |
_,candidates_df = sample_words(probs, word_id+1, input_sent)
|
261 |
st.table(candidates_df)
|
262 |
else:
|
263 |
-
disp_style = '"font-family:san serif; color:Black; font-size:
|
264 |
if explore_type=='Click through each step' and input_type=='Use your own initial sentence' and sent_id>0 and 'finished_sampling' in st.session_state:
|
265 |
sampled_loc = df.next_sample_loc.to_list()[sent_id-1]
|
266 |
disp_sent_before = f'<p style={disp_style}>'+' '.join(decoded_sent[1:sampled_loc])
|
|
|
79 |
return tsne
|
80 |
|
81 |
def clear_df():
|
82 |
+
if 'df' in st.session_state:
|
83 |
+
del st.session_state['df']
|
84 |
|
85 |
#@st.cache(show_spinner=False)
|
86 |
def plot_fig(df,sent_id,xlims,ylims,color_list):
|
|
|
166 |
|
167 |
if input_type=='Use one of the example sentences':
|
168 |
sentence = st.sidebar.selectbox("Select the inital sentence",
|
169 |
+
('--Please select one from below--',
|
170 |
+
'About 170 campers attend the camps each week.',
|
171 |
'She grew up with three brothers and ten sisters.'))
|
172 |
+
if sentence!='--Please select one from below--':
|
173 |
+
if sentence=='About 170 campers attend the camps each week.':
|
174 |
+
sentence_num = 6
|
175 |
+
elif sentence=='She grew up with three brothers and ten sisters.':
|
176 |
+
sentence_num = 8
|
177 |
+
st.session_state.df = load_data(sentence_num)
|
178 |
|
179 |
else:
|
180 |
sentence = st.sidebar.text_input('Type down your own sentence here.',on_change=clear_df)
|
|
|
257 |
st.write(decoded_sent[-1])
|
258 |
for word_id,(col,word) in enumerate(zip(cols[1:-1],decoded_sent[1:-1])):
|
259 |
with col:
|
260 |
+
if st.button(word,key=f'word_{word_id}'):
|
261 |
probs = mask_prob(model,mask_id,input_sent,word_id+1)
|
262 |
_,candidates_df = sample_words(probs, word_id+1, input_sent)
|
263 |
st.table(candidates_df)
|
264 |
else:
|
265 |
+
disp_style = '"font-family:san serif; color:Black; font-size: 20px; font-weight:bold"'
|
266 |
if explore_type=='Click through each step' and input_type=='Use your own initial sentence' and sent_id>0 and 'finished_sampling' in st.session_state:
|
267 |
sampled_loc = df.next_sample_loc.to_list()[sent_id-1]
|
268 |
disp_sent_before = f'<p style={disp_style}>'+' '.join(decoded_sent[1:sampled_loc])
|