taka-yamakoshi commited on
Commit
4ce3a07
1 Parent(s): fc55f20
Files changed (1) hide show
  1. app.py +14 -8
app.py CHANGED
@@ -109,7 +109,13 @@ def show_annotated_sentence(sent,option_locs=[],mask_locs=[]):
109
  style_list.append(f'{word}')
110
  disp = ' '.join(style_list)
111
  suffix = '</span></p>'
112
- return prefix + disp + suffix
 
 
 
 
 
 
113
 
114
  if __name__=='__main__':
115
  wide_setup()
@@ -123,7 +129,7 @@ if __name__=='__main__':
123
  st.session_state['page_status'] = 'type_in'
124
 
125
  if st.session_state['page_status']=='type_in':
126
- st.write('1. Type in the sentences and click "Tokenize"')
127
  sent_1 = st.text_input('Sentence 1',value='It is better to play a prank on Samuel than Craig because he gets angry less often.')
128
  sent_2 = st.text_input('Sentence 2',value='It is better to play a prank on Samuel than Craig because he gets angry more often.')
129
  if st.button('Tokenize'):
@@ -136,7 +142,7 @@ if __name__=='__main__':
136
  sent_1 = st.session_state['sent_1']
137
  sent_2 = st.session_state['sent_2']
138
 
139
- st.write('2. Select sites to mask out and click "Confirm"')
140
  annotate_mask(1,sent_1)
141
  annotate_mask(2,sent_2)
142
  if st.button('Confirm',key='mask'):
@@ -147,7 +153,7 @@ if __name__=='__main__':
147
  sent_1 = st.session_state['sent_1']
148
  sent_2 = st.session_state['sent_2']
149
 
150
- st.write('2. Select options and click "Confirm"')
151
  annotate_options(1,sent_1)
152
  annotate_options(2,sent_2)
153
  if st.button('Confirm',key='option'):
@@ -158,12 +164,12 @@ if __name__=='__main__':
158
  with main_area.container():
159
  sent_1 = st.session_state['sent_1']
160
  sent_2 = st.session_state['sent_2']
161
- st.markdown(show_annotated_sentence(st.session_state['decoded_sent_1'],
162
  option_locs=st.session_state['option_locs_1'],
163
- mask_locs=st.session_state['mask_locs_1']), unsafe_allow_html = True)
164
- st.markdown(show_annotated_sentence(st.session_state['decoded_sent_2'],
165
  option_locs=st.session_state['option_locs_2'],
166
- mask_locs=st.session_state['mask_locs_2']), unsafe_allow_html = True)
167
 
168
  input_ids_1 = tokenizer(sent_1).input_ids
169
  input_ids_2 = tokenizer(sent_2).input_ids
 
109
  style_list.append(f'{word}')
110
  disp = ' '.join(style_list)
111
  suffix = '</span></p>'
112
+ return st.markdown(prefix + disp + suffix, unsafe_allow_html = True)
113
+
114
+ def show_instruction(sent):
115
+ disp_style = '"font-family:san serif; color:Black; font-size: 20px"'
116
+ prefix = f'<p style={disp_style}><span style="font-weight:bold">'
117
+ suffix = '</span></p>'
118
+ return st.markdown(prefix + sent + suffix, unsafe_allow_html = True)
119
 
120
  if __name__=='__main__':
121
  wide_setup()
 
129
  st.session_state['page_status'] = 'type_in'
130
 
131
  if st.session_state['page_status']=='type_in':
132
+ show_instruction('1. Type in the sentences and click "Tokenize"')
133
  sent_1 = st.text_input('Sentence 1',value='It is better to play a prank on Samuel than Craig because he gets angry less often.')
134
  sent_2 = st.text_input('Sentence 2',value='It is better to play a prank on Samuel than Craig because he gets angry more often.')
135
  if st.button('Tokenize'):
 
142
  sent_1 = st.session_state['sent_1']
143
  sent_2 = st.session_state['sent_2']
144
 
145
+ show_instruction('2. Select sites to mask out and click "Confirm"')
146
  annotate_mask(1,sent_1)
147
  annotate_mask(2,sent_2)
148
  if st.button('Confirm',key='mask'):
 
153
  sent_1 = st.session_state['sent_1']
154
  sent_2 = st.session_state['sent_2']
155
 
156
+ show_instruction('3. Select options and click "Confirm"')
157
  annotate_options(1,sent_1)
158
  annotate_options(2,sent_2)
159
  if st.button('Confirm',key='option'):
 
164
  with main_area.container():
165
  sent_1 = st.session_state['sent_1']
166
  sent_2 = st.session_state['sent_2']
167
+ show_annotated_sentence(st.session_state['decoded_sent_1'],
168
  option_locs=st.session_state['option_locs_1'],
169
+ mask_locs=st.session_state['mask_locs_1'])
170
+ show_annotated_sentence(st.session_state['decoded_sent_2'],
171
  option_locs=st.session_state['option_locs_2'],
172
+ mask_locs=st.session_state['mask_locs_2'])
173
 
174
  input_ids_1 = tokenizer(sent_1).input_ids
175
  input_ids_2 = tokenizer(sent_2).input_ids