Spaces:
Runtime error
Runtime error
File size: 896 Bytes
58f2a4f 9bc72c0 58f2a4f 6b6b034 bf022fc c08a1e4 6c64c23 c08a1e4 d96a8c9 6c64c23 c08a1e4 f76cd25 7ee86f4 fec1ca0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
from transformers import pipeline
import streamlit as st
import re
unmasker = pipeline('fill-mask', model='distilbert-base-cased')
def main():
with st.form("Mask_filling_form"):
st.title('EN sentence mask filling')
st.markdown('Mask a word with [MASK]. For example, **I [MASK] dog for a walk**')
masked = st.text_input('Masked sentence','Please insert a sentence')
submitted = st.form_submit_button("Submit")
if submitted:
mask_str = '[MASK]'
mask_check = bool(re.search(mask_str, masked))
if mask_check:
st.success("Submitted")
output = unmasker(masked)
st.write('Filled sentence:',output[0]['sequence'])
else:
st.error('Sentence is not masked!!!')
if __name__ == "__main__":
main() |