import gradio as gr from kwextractor import KeyWordExtractor def greet(name): return "Hello " + name + "!!" kw_ex=KeyWordExtractor() def generate_kws(context,num_kw): context=context.strip() if context: try: num_kw=int(num_kw) except ValueError: num_kw=None return kw_ex.extract(context, num_kw) or "" return result else: raise gr.Error("Please enter text in inputbox!!!!") inputs=gr.Textbox(value=article_value, lines=5, label="Input Context",elem_id="inp_div") nkws = gr.Textbox(label="Number of keywords to extract",elem_id="inp_div") outputs=gr.Textbox(label="Generated Keywords",lines=6,elem_id="inp_div") demo = gr.Interface( generate_kws, [inputs,nkws], outputs, title="Keyword Extraction Model", css=".gradio-container {background-color: lightgray} #inp_div {background-color: #7FB3D5;}", article="""
Feel free to give us your feedback on this Keyword Extraction demo.
""" ) demo.launch()