Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,23 +5,24 @@ import re
|
|
| 5 |
unmasker = pipeline('fill-mask', model='distilbert-base-uncased')
|
| 6 |
|
| 7 |
def main():
|
| 8 |
-
st.
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
submitted = st.form_submit_button("Submit")
|
| 13 |
-
|
| 14 |
-
if submitted:
|
| 15 |
-
mask_str = '[MASK]'
|
| 16 |
-
mask_check = re.search(masked, mask_str)
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
if __name__ == "__main__":
|
| 27 |
main()
|
|
|
|
| 5 |
unmasker = pipeline('fill-mask', model='distilbert-base-uncased')
|
| 6 |
|
| 7 |
def main():
|
| 8 |
+
with st.form("Mask_filling_form"):
|
| 9 |
+
st.title('EN sentence mask filling')
|
| 10 |
+
st.markdown('Mask a word with [MASK]. For example, **I [MASK] dog for a walk**')
|
| 11 |
+
masked = st.text_input('Masked sentence','Please insert a sentence')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
submitted = st.form_submit_button("Submit")
|
| 14 |
+
|
| 15 |
+
if submitted:
|
| 16 |
+
mask_str = '[MASK]'
|
| 17 |
+
mask_check = re.search(masked, mask_str)
|
| 18 |
|
| 19 |
+
if mask_check:
|
| 20 |
+
st.success("Submitted")
|
| 21 |
+
output = unmasker(masked)
|
| 22 |
+
|
| 23 |
+
st.write('Filled sentence:',output[0]['sequence'])
|
| 24 |
+
else:
|
| 25 |
+
st.error('Sentence is not masked!!!')
|
| 26 |
|
| 27 |
if __name__ == "__main__":
|
| 28 |
main()
|