Spaces:
Sleeping
Sleeping
File size: 733 Bytes
4a0869b 049ebbc b783377 049ebbc b2bb994 4a0869b dc886e0 81dcda2 4a0869b |
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 |
import gradio as gr
from transformers import pipeline
from normalizer import cleaning
pipe = pipeline("fill-mask", model="HooshvareLab/albert-fa-zwnj-base-v2")
def greet(text):
text = cleaning(text)
results = pipe(text)
result_str = ''
for result in results:
result_str += result['token_str'] + \
' (' + str(result['score']) + ')' + \
'\n' + result['sequence'] + '\n\n'
return result_str
demo = gr.Interface(fn=greet, inputs=gr.Textbox(label='input text'), outputs=gr.Textbox(label="output text:"),
allow_flagging='never',
examples=['آسمان [MASK] است.',
'هوا [MASK] است.'])
demo.launch()
|