Arabic-KW / app.py
medmediani
Changed the model path
37ec07c
import gradio as gr
from kwextractor import KeyWordExtractor
import csv, io
kw_ex=KeyWordExtractor()
csv_encoded=io.StringIO()
writer = csv.writer(csv_encoded)
def generate_kws(context,num_kw, kw_ngs):
context=context.strip()
if context:
try:
num_kw=int(num_kw)
except ValueError:
num_kw=None
try:
kw_ngs=int(kw_ngs)
except ValueError:
kw_ngs=None
#csv_encoded.truncate(0)
#writer.writerow([context])
#context=csv_encoded.getvalue()
return kw_ex.extract(context, num_kw, kw_ngs) or ""
else:
raise gr.Error("Please enter text in inputbox!!!!")
inputs=gr.Textbox(value="", lines=5, label="Input Context",elem_id="inp_div")
nkws = gr.Textbox(label="Number of keywords to extract",default="3",elem_id="inp_div")
kw_ngs= gr.Textbox(label="Maximum number of ngrams per keyword",default="3",elem_id="inp_div")
outputs=gr.Textbox(label="Generated Keywords",lines=6,elem_id="inp_div")
demo = gr.Interface(
generate_kws,
[inputs,nkws,kw_ngs],
outputs,
title="Keyword Extraction Model",
css=".gradio-container {background-color: lightgray} #inp_div {background-color: #7FB3D5;}",
article="""<p style='text-align: center;'>Feel free to give us your <a href="https://www.pragnakalp.com/contact/" target="_blank">feedback</a> on this Keyword Extraction demo.</p>
"""
)
demo.launch()