taka-yamakoshi commited on
Commit
1567a0f
·
1 Parent(s): 10ced5b
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -87,7 +87,7 @@ if __name__=='__main__':
87
  st.write('2. Select sites to mask out and click "Confirm"')
88
  input_sent = tokenizer(sent_1).input_ids
89
  decoded_sent = [tokenizer.decode([token]) for token in input_sent[1:-1]]
90
- char_nums = [len(word)+2 for word in decoded_sent]
91
  st.write(char_nums)
92
  cols = st.columns(char_nums)
93
  for word_id,(col,word) in enumerate(zip(cols,decoded_sent)):
@@ -95,6 +95,8 @@ if __name__=='__main__':
95
  if st.button(word,key=f'word_{word_id}'):
96
  if word_id not in st.session_state['masked_pos_1']:
97
  st.session_state['masked_pos_1'].append(word_id)
 
 
98
  st.write(f'Masked words: {", ".join([decoded_sent[word_id] for word_id in np.sort(st.session_state["masked_pos_1"])])}')
99
 
100
 
 
87
  st.write('2. Select sites to mask out and click "Confirm"')
88
  input_sent = tokenizer(sent_1).input_ids
89
  decoded_sent = [tokenizer.decode([token]) for token in input_sent[1:-1]]
90
+ char_nums = [len(word)+3 for word in decoded_sent]
91
  st.write(char_nums)
92
  cols = st.columns(char_nums)
93
  for word_id,(col,word) in enumerate(zip(cols,decoded_sent)):
 
95
  if st.button(word,key=f'word_{word_id}'):
96
  if word_id not in st.session_state['masked_pos_1']:
97
  st.session_state['masked_pos_1'].append(word_id)
98
+ else:
99
+ _ = st.session_state['masked_pos_1'].pop(word_id)
100
  st.write(f'Masked words: {", ".join([decoded_sent[word_id] for word_id in np.sort(st.session_state["masked_pos_1"])])}')
101
 
102