taka-yamakoshi
commited on
Commit
•
b6390e8
1
Parent(s):
2b66ae3
debug
Browse files
app.py
CHANGED
@@ -68,12 +68,13 @@ def annotate_mask(sent_id,sent):
|
|
68 |
st.session_state[f'mask_locs_{sent_id}'] = []
|
69 |
for word_id,(col,word) in enumerate(zip(cols,decoded_sent)):
|
70 |
with col:
|
71 |
-
if st.button(word,key=f'
|
72 |
if word_id not in st.session_state[f'mask_locs_{sent_id}']:
|
73 |
st.session_state[f'mask_locs_{sent_id}'].append(word_id)
|
74 |
else:
|
75 |
st.session_state[f'mask_locs_{sent_id}'].remove(word_id)
|
76 |
-
st.markdown(show_annotated_sentence(decoded_sent,
|
|
|
77 |
|
78 |
def annotate_options(sent_id,sent):
|
79 |
st.write(f'Sentence {sent_id}')
|
@@ -81,17 +82,18 @@ def annotate_options(sent_id,sent):
|
|
81 |
decoded_sent = [tokenizer.decode([token]) for token in input_sent[1:-1]]
|
82 |
char_nums = [len(word)+2 for word in decoded_sent]
|
83 |
cols = st.columns(char_nums)
|
84 |
-
|
|
|
85 |
for word_id,(col,word) in enumerate(zip(cols,decoded_sent)):
|
86 |
with col:
|
87 |
-
if st.button(word,key=f'
|
88 |
-
if word_id not in
|
89 |
-
|
90 |
else:
|
91 |
-
|
92 |
-
st.markdown(show_annotated_sentence(decoded_sent,
|
|
|
93 |
mask_locs=st.session_state[f'mask_locs_{sent_id}']), unsafe_allow_html = True)
|
94 |
-
st.session_state[f'option_locs_{sent_id}'] = option_locs
|
95 |
|
96 |
def show_annotated_sentence(sent,option_locs=[],mask_locs=[]):
|
97 |
disp_style = '"font-family:san serif; color:Black; font-size: 20px"'
|
|
|
68 |
st.session_state[f'mask_locs_{sent_id}'] = []
|
69 |
for word_id,(col,word) in enumerate(zip(cols,decoded_sent)):
|
70 |
with col:
|
71 |
+
if st.button(word,key=f'word_mask_{sent_id}_{word_id}'):
|
72 |
if word_id not in st.session_state[f'mask_locs_{sent_id}']:
|
73 |
st.session_state[f'mask_locs_{sent_id}'].append(word_id)
|
74 |
else:
|
75 |
st.session_state[f'mask_locs_{sent_id}'].remove(word_id)
|
76 |
+
st.markdown(show_annotated_sentence(decoded_sent,
|
77 |
+
mask_locs=st.session_state[f'mask_locs_{sent_id}']), unsafe_allow_html = True)
|
78 |
|
79 |
def annotate_options(sent_id,sent):
|
80 |
st.write(f'Sentence {sent_id}')
|
|
|
82 |
decoded_sent = [tokenizer.decode([token]) for token in input_sent[1:-1]]
|
83 |
char_nums = [len(word)+2 for word in decoded_sent]
|
84 |
cols = st.columns(char_nums)
|
85 |
+
if f'option_locs_{sent_id}' not in st.session_state:
|
86 |
+
st.session_state[f'option_locs_{sent_id}'] = []
|
87 |
for word_id,(col,word) in enumerate(zip(cols,decoded_sent)):
|
88 |
with col:
|
89 |
+
if st.button(word,key=f'word_option_{sent_id}_{word_id}'):
|
90 |
+
if word_id not in st.session_state[f'option_locs_{sent_id}']:
|
91 |
+
st.session_state[f'option_locs_{sent_id}'].append(word_id)
|
92 |
else:
|
93 |
+
st.session_state[f'option_locs_{sent_id}'].remove(word_id)
|
94 |
+
st.markdown(show_annotated_sentence(decoded_sent,
|
95 |
+
option_locs=st.session_state[f'option_locs_{sent_id}'],
|
96 |
mask_locs=st.session_state[f'mask_locs_{sent_id}']), unsafe_allow_html = True)
|
|
|
97 |
|
98 |
def show_annotated_sentence(sent,option_locs=[],mask_locs=[]):
|
99 |
disp_style = '"font-family:san serif; color:Black; font-size: 20px"'
|