kcarnold commited on
Commit
c41b2aa
1 Parent(s): 87bf1cf

Deal with multi-word predictions

Browse files
Files changed (1) hide show
  1. pages/1_Rewrite.py +6 -2
pages/1_Rewrite.py CHANGED
@@ -25,7 +25,11 @@ def append_token(word):
25
  st.session_state['rewrite_in_progress'] + word
26
  )
27
 
28
- for col, token in zip(st.columns(len(tokens)), tokens):
 
 
29
  with col:
30
- st.button(token, on_click=append_token, args=(token,))
 
 
31
 
 
25
  st.session_state['rewrite_in_progress'] + word
26
  )
27
 
28
+ allow_multi_word = st.checkbox("Allow multi-word predictions", value=False)
29
+
30
+ for i, (col, token) in enumerate(zip(st.columns(len(tokens)), tokens)):
31
  with col:
32
+ if not allow_multi_word and ' ' in token[1:]:
33
+ token = token[0] + token[1:].split(' ', 1)[0]
34
+ st.button(token, on_click=append_token, args=(token,), key=i)
35